commit e08dba043a9bc3798a1d5681089789fdf3b38689
parent 57d3ee19eb6cf8bdb5a081ad696b3415cac3240a
Author: Konstantin Tarkus <koistya@gmail.com>
Date: Mon, 7 Mar 2016 11:06:55 +0300
Merge pull request #484 from cpojer/master
Update to Jest 0.9.0 and add an example with enzyme.
Diffstat:
5 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/.eslintrc b/.eslintrc
@@ -4,6 +4,10 @@
"globals": {
"__DEV__": true
},
+ "env": {
+ "browser": true,
+ "jest": true
+ },
"rules": {
"no-confusing-arrow": 0,
"react/jsx-quotes": 0,
diff --git a/package.json b/package.json
@@ -42,6 +42,7 @@
"autoprefixer": "^6.3.3",
"babel-cli": "^6.6.0",
"babel-eslint": "^5.0.0",
+ "babel-jest": "^9.0.0",
"babel-loader": "^6.2.4",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-runtime": "^6.6.0",
@@ -53,17 +54,19 @@
"css-loader": "^0.23.1",
"csscomb": "^3.1.8",
"del": "^2.2.0",
+ "enzyme": "^2.0.0",
"eslint": "^2.2.0",
"eslint-config-airbnb": "^6.0.2",
"eslint-loader": "^1.3.0",
"eslint-plugin-react": "^4.1.0",
+ "estraverse-fb": "^1.3.1",
"extend": "^3.0.0",
"file-loader": "^0.8.5",
"gaze": "^0.5.2",
"git-repository": "^0.1.1",
"glob": "^7.0.0",
"jade-loader": "^0.8.0",
- "jest-cli": "^0.8.2",
+ "jest-cli": "^0.9.0",
"jscs": "^2.11.0",
"json-loader": "^0.5.4",
"mkdirp": "^0.5.1",
@@ -74,6 +77,7 @@
"postcss-scss": "^0.1.6",
"precss": "^1.4.0",
"raw-loader": "^0.5.1",
+ "react-addons-test-utils": "^0.14.7",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.2",
"redbox-react": "^1.2.2",
@@ -85,10 +89,16 @@
},
"jest": {
"rootDir": "./src",
- "scriptPreprocessor": "../preprocessor.js",
+ "testPathDirs": [
+ "<rootDir>",
+ "<rootDir>/../test/"
+ ],
+ "moduleNameMapper": {
+ "\\.scss$": "SCSSStub"
+ },
"unmockedModulePathPatterns": [
- "fbjs",
- "react"
+ "react",
+ "enzyme"
]
},
"scripts": {
diff --git a/preprocessor.js b/preprocessor.js
@@ -1,26 +0,0 @@
-/**
- * React Starter Kit (https://www.reactstarterkit.com/)
- *
- * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE.txt file in the root directory of this source tree.
- */
-
-'use strict';
-
-var babel = require('babel-core');
-
-module.exports = {
- process: function(src, filename) {
- // Ignore files other than .js, .es, .jsx or .es6
- if (!babel.canCompile(filename)) {
- return '';
- }
- // Ignore all files within node_modules
- if (filename.indexOf('node_modules') === -1) {
- return babel.transform(src, {filename: filename}).code;
- }
- return src;
- }
-};
diff --git a/src/components/App/__tests__/App-test.js b/src/components/App/__tests__/App-test.js
@@ -0,0 +1,16 @@
+jest.unmock('../App');
+
+import App from '../App';
+import React from 'react';
+import { shallow } from 'enzyme';
+
+describe('App', () => {
+ it('renders children correctly', () => {
+ const wrapper = shallow(
+ <App context={{ insertCss: () => {} }}>
+ <div className="child" />
+ </App>
+ );
+ expect(wrapper.contains(<div className="child" />)).toBe(true);
+ });
+});
diff --git a/test/stubs/SCSSStub.js b/test/stubs/SCSSStub.js
@@ -0,0 +1,5 @@
+/**
+ * @providesModule SCSSStub
+ */
+
+module.exports = {};