jasmine-expect-jsx
Adds toEqualJSX
and toIncludeJSX
methods to jasmine assertions.
Uses Algolia's react-element-to-jsx-string under the hood.
Installation
npm install -D jasmine-expect-jsx
Setup
Browser
Karma
Integration is easy with the karma-jasmine-expect-jsx plugin and it provides colored output.
Also you can just add 'node_modules/jasmine-expect-jsx/dist/jasmine-expect-jsx.js'
to files section of your config.
Node.js
;
Jest
- Add
setupTestFrameworkScriptFile
inpackage.json
- Import
jasmine-expect-jsx
insetupTestFrameworkScriptFile
file
// jestSetup.js;
Usage
The following tests are all passing:
Expect
Component {} // equalJSX;; not;not; // includeJSX;; // assuming <SomeSubComponent /> is rendered by TestComponent's render not;not; // assuming <SomeSubComponent /> is not rendered by TestComponent's render