Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Weekly downloads
9
80%
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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.