New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

karma-jasmine-expect-jsx

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-jasmine-expect-jsx

A Karma plugin. Adds toEqualJSX matcher for the Jasmine BDD JavaScript testing library.

2.0.0
latest
Source
npm
Version published
Weekly downloads
43
207.14%
Maintainers
1
Weekly downloads
 
Created
Source

karma-jasmine-expect-jsx

A Karma plugin to inject jasmine-expect-jsx for Jasmine.

Installation

npm

npm install karma-jasmine-expect-jsx --save-dev

Integration

Karma

Just include 'jasmine-expect-jsx' in the frameworks section of your config. If you want colored output add 'jasmine-expect-jsx' in reporters section before others.

module.exports = function(config) {
    config.set({
        frameworks: [
            'jasmine',
            'jasmine-expect-jsx'
        ],
        reporters: [
            'jasmine-expect-jsx',
            'spec'
        ],
        files: [
            'src/**/*.js',
            'src/**/*.spec.js'
        ]
    });
};

Usage

The following tests are all passing:

class TestComponent extends React.Component {}

// equalJSX
expect(<div />).toEqualJSX(<div />);
expect(<TestComponent />).toEqualJSX(<TestComponent />);

expect(<div />).not.toEqualJSX(<span />);
expect(<TestComponent />).not.toEqualJSX(<span />);

// includeJSX
expect(<div><span>Hello World!</span></div>).toIncludeJSX(<span>Hello World!</span>);
expect(<TestComponent />).toIncludeJSX(<SomeSubComponent />); // assuming <SomeSubComponent /> is rendered by TestComponent's render

expect(<div><span>Hello World!</span></div>).not.toIncludeJSX(<span>Hello World!</span>);
expect(<TestComponent />).not.toIncludeJSX(<SomeSubComponent />); // assuming <SomeSubComponent /> is not rendered by TestComponent's render

Keywords

karma-plugin

FAQs

Package last updated on 27 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts