diff --git a/client/.gitignore b/client/.gitignore index a8187ae69..74baa49d8 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -1,3 +1,4 @@ node_modules build/app.js build/*[woff2?|ttf|eot|svg] +coverage/ diff --git a/client/app/scripts/components/__tests__/node-details-test.js b/client/app/scripts/components/__tests__/node-details-test.js index 7fc1d2dc1..655751aa4 100644 --- a/client/app/scripts/components/__tests__/node-details-test.js +++ b/client/app/scripts/components/__tests__/node-details-test.js @@ -1,3 +1,7 @@ +jest.dontMock('../node-details.js'); +jest.dontMock('../../mixins/node-color-mixin'); +jest.dontMock('../../utils/title-utils'); + describe('NodeDetails', () => { let NodeDetails; let nodes; @@ -28,4 +32,4 @@ describe('NodeDetails', () => { expect(title.getDOMNode().textContent).toBe('Node 1'); }); -}); \ No newline at end of file +}); diff --git a/client/app/scripts/stores/__tests__/app-store-test.js b/client/app/scripts/stores/__tests__/app-store-test.js index 3dd4f17e3..197c58610 100644 --- a/client/app/scripts/stores/__tests__/app-store-test.js +++ b/client/app/scripts/stores/__tests__/app-store-test.js @@ -1,7 +1,11 @@ +jest.dontMock('../../constants/action-types'); +jest.dontMock('../app-store'); + // Appstore test suite using Jasmine matchers describe('AppStore', function() { const ActionTypes = require('../../constants/action-types'); + let AppDispatcher; let AppStore; let registeredCallback; @@ -121,10 +125,9 @@ describe('AppStore', function() { }; beforeEach(function() { - // clear AppStore singleton - delete require.cache[require.resolve('../app-store')]; + AppDispatcher = require('../../dispatcher/app-dispatcher'); AppStore = require('../app-store'); - registeredCallback = AppStore.registeredCallback; + registeredCallback = AppDispatcher.register.mock.calls[0][0]; }); // topology tests @@ -309,4 +312,4 @@ describe('AppStore', function() { expect(AppStore.getAdjacentNodes().size).toEqual(0); }); -}); \ No newline at end of file +}); diff --git a/client/package.json b/client/package.json index 841e743ab..d80dc3afe 100644 --- a/client/package.json +++ b/client/package.json @@ -19,10 +19,9 @@ "materialize-css": "^0.96.1", "object-assign": "^2.0.0", "page": "^1.6.3", - "react": "^0.13.3", + "react": "0.13.3", "react-motion": "^0.2.7", "react-tap-event-plugin": "^0.1.7", - "react-tween-state": "0.0.5", "reqwest": "~1.1.5", "timely": "^0.1.0" }, @@ -30,6 +29,7 @@ "autoprefixer-core": "^5.2.0", "babel-core": "^5.4.7", "babel-eslint": "^3.1.9", + "babel-jest": "^5.3.0", "babel-loader": "^5.1.3", "css-loader": "^0.14.4", "eslint": "^0.21.2", @@ -39,22 +39,13 @@ "express": "^4.13.3", "express-http-proxy": "^0.6.0", "file-loader": "^0.8.4", - "istanbul-instrumenter-loader": "^0.1.3", - "jasmine-core": "^2.3.4", + "jest-cli": "0.4.19", "json-loader": "^0.5.2", - "karma": "^0.13.3", - "karma-cli": "0.0.4", - "karma-coverage": "^0.4.2", - "karma-jasmine": "^0.3.5", - "karma-phantomjs-launcher": "^0.1.4", - "karma-webpack": "^1.7.0", "less": "^2.5.1", "less-loader": "^2.2.0", - "phantomjs": "^1.9.18", "postcss-loader": "^0.4.3", "proxy-middleware": "^0.13.1", "react-hot-loader": "^1.2.8", - "react-tools": "^0.13.3", "style-loader": "^0.12.3", "url": "^0.10.3", "url-loader": "^0.5.6", @@ -62,15 +53,35 @@ "webpack-dev-server": "^1.10.1" }, "scripts": { - "postinstall": "npm run build", "build": "webpack -p --config webpack.production.config.js", "start": "node server.js", "start-production": "NODE_ENV=production node server.js", - "test": "karma start test/karma.conf.js --single-run", + "test": "jest --coverage", "coveralls": "cat coverage/lcov.info | coveralls", "lint": "eslint app", "clean": "rm build/app.js" }, + "jest": { + "scriptPreprocessor": "/node_modules/babel-jest", + "testFileExtensions": [ + "es6", + "js" + ], + "moduleFileExtensions": [ + "js", + "json", + "es6" + ], + "unmockedModulePathPatterns": [ + "react", + "immutable", + "d3", + "keymirror", + "object-assign", + "lodash", + "debug" + ] + }, "engines": { "node": ">=0.10.0" }