Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Configure webpack for enzyme
Browse files Browse the repository at this point in the history
- Move NODE_ENV=test to npm scripts
- Add enzyme externals to webpack test configuration
  • Loading branch information
adborden committed Jan 20, 2017
1 parent 8a212f9 commit d5d4621
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Expand Up @@ -38,7 +38,7 @@ test:
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
override:
- cd $WS && ./codecheck.sh -u
- cd $WS && NODE_ENV="test" npm test
- cd $WS && npm test

deployment:
deploy:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -13,10 +13,10 @@
"check-style": "/bin/bash -c '[[ $(npm ls cloudgov-style) =~ \"git://github.com\" ]] && npm run build-style || exit 0'",
"clean": "rm -rf ./static/assets/*",
"lint": "eslint --ext .js --ext .jsx ./static_src",
"test": "npm run lint && karma start --single-run",
"test": "export NODE_ENV=test && npm run lint && karma start --single-run",
"testing-server": "node ./static_src/test/server/server.js",
"watch-server": "npm run testing-server & npm run watch",
"watch-test": "karma start --browsers Chrome",
"watch-test": "export NODE_ENV=test && karma start --browsers Chrome",
"watch": "webpack --watch"
},
"author": "Marco Segreto (marco.segreto@gsa.gov)",
Expand Down
2 changes: 2 additions & 0 deletions static_src/test/global_setup.js
@@ -1,6 +1,7 @@

require('babel-polyfill');

import jasmineEnzyme from 'jasmine-enzyme';

Function.prototype.bind = Function.prototype.bind || function (thisp) {
var fn = this;
Expand Down Expand Up @@ -212,6 +213,7 @@ function createJasmineSinonMatchers(matchers) {
}

beforeEach(function() {
jasmineEnzyme();
jasmine.addMatchers(createJasmineSinonMatchers(sinonMatchers));
//jasmine.addMatchers(reactMatchers);
});
Expand Down
6 changes: 6 additions & 0 deletions webpack.config.js
Expand Up @@ -89,6 +89,12 @@ const config = {

if (TEST) {
config.plugins.push(new WebpackKarmaWarningsPlugin());
config.externals = {
'cheerio': 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
};
}

if (PRODUCTION) {
Expand Down

0 comments on commit d5d4621

Please sign in to comment.