An open API service indexing awesome lists of open source software.

https://github.com/smacker/karma-jasmine-expect-jsx

A Karma plugin. Adds toEqualJSX matcher for the Jasmine BDD JavaScript testing library.
https://github.com/smacker/karma-jasmine-expect-jsx

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

# karma-jasmine-expect-jsx

> A [Karma](http://karma-runner.github.io/) plugin to inject [jasmine-expect-jsx](https://github.com/smacker/jasmine-expect-jsx) for [Jasmine](http://jasmine.github.io/).

## Installation

### npm

```bash
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.

```javascript
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:

```javascript
class TestComponent extends React.Component {}

// equalJSX
expect(

).toEqualJSX(
);
expect().toEqualJSX();

expect(

).not.toEqualJSX();
expect().not.toEqualJSX();

// includeJSX
expect(

Hello World!
).toIncludeJSX(Hello World!);
expect().toIncludeJSX(); // assuming is rendered by TestComponent's render

expect(

Hello World!
).not.toIncludeJSX(Hello World!);
expect().not.toIncludeJSX(); // assuming is not rendered by TestComponent's render
```