-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: Migrate tests to Jest #199
Changes from 4 commits
36cd579
74f325b
e492151
da9114d
4390bde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ Install the following plugins in your preferred editor | |
|
||
* `yarn run build` to generate resource bundles and JS webpack bundles. | ||
* `yarn run watch` to only generate JS webpack bundles on file changes. | ||
* `yarn run test` launches karma tests with PhantomJS. | ||
* `yarn run test` launches jest tests with PhantomJS. | ||
* `yarn run test -- --src=PATH/TO/SRC/FILENAME` launches test only for `src/PATH/TO/SRC/__tests__/FILENAME-test.js` instead of all tests. For example, `yarn run test -- --src=doc/DocAnnotator` launches tests for `src/doc/__tests__/DocAnnotator-test.js`. This also works for directories, e.g. `yarn run test -- --src=doc/`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jest can filter by default right? We can remove all of this -- --src business |
||
* `yarn run debug` launches karma tests with PhantomJS for debugging. Open the URL mentioned in the console. | ||
* `yarn run debug` launches jest tests with PhantomJS for debugging. Open the URL mentioned in the console. | ||
* `yarn run debug -- --src=path/to/src/FILENAME` launches debugging for `src/path/to/src/__tests__/FILENAME-test.js` instead of all tests. Open the URL mentioned in the console. | ||
|
||
For more script commands see `package.json`. Test coverage reports are available under reports/coverage. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.2.3", | ||
"babel-jest": "^23.4.2", | ||
"babel-loader": "^7.1.2", | ||
"babel-plugin-istanbul": "^4.1.6", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
|
@@ -38,6 +38,7 @@ | |
"conventional-github-releaser": "^2.0.0", | ||
"css-loader": "^0.28.7", | ||
"cssnano-cli": "^1.0.5", | ||
"enzyme-to-json": "^3.3.4", | ||
"eslint": "^4.12.1", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
|
@@ -50,22 +51,8 @@ | |
"fetch-mock": "^6.0.0", | ||
"fetch-mock-forwarder": "^1.0.0", | ||
"husky": "^0.14.3", | ||
"karma": "^2.0.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-chai-dom": "^1.1.0", | ||
"karma-chai-sinon": "^0.1.5", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-fixture": "^0.2.6", | ||
"karma-html2js-preprocessor": "^1.1.0", | ||
"karma-junit-reporter": "^1.2.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"karma-sinon": "^1.0.5", | ||
"karma-sinon-stub-promise": "^1.0.0", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^2.0.6", | ||
"jest": "^23.5.0", | ||
"jest-canvas-mock": "^1.1.0", | ||
"lint-staged": "^7.0.4", | ||
"mocha": "^5.1.1", | ||
"node-noop": "^1.0.0", | ||
|
@@ -94,8 +81,8 @@ | |
"scripts": { | ||
"build": "yarn install && BABEL_ENV=production NODE_ENV=production CI=1 node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js -p --progress --colors --config build/webpack.config.js", | ||
"watch": "yarn install && BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --watch --progress --colors --config build/webpack.config.js", | ||
"test": "yarn install && NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js", | ||
"debug": "yarn install && NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js --no-single-run --auto-watch", | ||
"test": "yarn install && NODE_ENV=test yarn run jest", | ||
"debug": "yarn install && NODE_ENV=test yarn run jest --watch", | ||
"setup-travis": "cd functional-tests && yarn install && node app.js", | ||
"selenium-build": "BABEL_ENV=production NODE_ENV=production CI=1 node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js -p --progress --colors --config build/webpack.selenium.config.js", | ||
"functional-tests": "node functional-tests/app.js & node ./node_modules/codeceptjs/bin/codecept.js run --steps", | ||
|
@@ -120,5 +107,29 @@ | |
"prettier-eslint --print-width 120 --single-quote --tab-width 4 --write", | ||
"git add" | ||
] | ||
}, | ||
"jest": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to break this out in a separate config file like we did for karma? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this actually needs to be in package.json |
||
"clearMocks": true, | ||
"globals": { | ||
"__NAME__": "name", | ||
"__VERSION__": "version" | ||
}, | ||
"setupFiles": [ | ||
"jest-canvas-mock" | ||
], | ||
"moduleNameMapper": { | ||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test-utils/fileMock.js", | ||
"\\.(css|less|html)$": "<rootDir>/test-utils/styleMock.js" | ||
}, | ||
"transformIgnorePatterns": [ | ||
"node_modules/(?!(box-react-ui)/)" | ||
], | ||
"collectCoverage": false, | ||
"coverageDirectory": "<rootDir>/reports", | ||
"collectCoverageFrom": [ | ||
"src/**/*.js", | ||
"!**/node_modules/**", | ||
"!**/__tests__/**" | ||
] | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does jest also use phantom? I only see it being removed in configs/ package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove it!