Permalink
Browse files

Add snapshot test when using enzyme

  • Loading branch information...
takayukii committed Mar 20, 2017
1 parent 39104a1 commit b05bbae0c2e4c8232e38c4c079d4b063d84f2c3f
Showing with 336 additions and 2 deletions.
  1. +3 −0 .jestrc
  2. +4 −1 package.json
  3. +19 −0 src/__tests__/__snapshots__/test-enzyme.js.snap
  4. +13 −0 src/__tests__/test-enzyme.js
  5. +297 −1 yarn.lock
View
@@ -0,0 +1,3 @@
+{
+ "snapshotSerializers": ["./node_modules/jest-serializer-enzyme"]
+}
View
@@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --progress --inline --hot",
- "test": "jest"
+ "test": "jest --config .jestrc"
},
"author": "",
"license": "ISC",
@@ -15,8 +15,11 @@
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-react-hmre": "^1.1.1",
+ "enzyme": "^2.7.1",
"jest": "^19.0.2",
+ "jest-serializer-enzyme": "^1.0.0",
"react": "^15.4.2",
+ "react-addons-test-utils": "^15.4.2",
"react-dom": "^15.4.2",
"react-test-renderer": "^15.4.2",
"webpack": "^2.2.1",
@@ -0,0 +1,19 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Greeting Hello enzyme is displayed? 1`] = `
+<App
+ greeting="Hello enzyme"
+>
+ <div
+ className="container"
+ >
+ <div
+ className="jumbotron"
+ >
+ <h1>
+ Hello enzyme
+ </h1>
+ </div>
+ </div>
+</App>
+`;
@@ -0,0 +1,13 @@
+import React from 'react';
+import {mount} from 'enzyme';
+
+import App from '../App';
+
+describe('<App/>', () => {
+ it('snapshot2', () => {
+ const wrapper = mount(
+ <App greeting="Hello enzyme"/>
+ );
+ expect(wrapper).toMatchSnapshot('Greeting Hello enzyme is displayed?');
+ });
+});
Oops, something went wrong.

0 comments on commit b05bbae

Please sign in to comment.