Skip to content

Commit

Permalink
Fix jest test suite by setting up babel-jest
Browse files Browse the repository at this point in the history
Oops. Turns out we actually need to use babel in this project. We don't
need to use it to build the Chrome extension, BUT we DO need to use it
to run the tests correctly in the node environment. This restores
jest and configures it to only run for jest with the node preset.
  • Loading branch information
davidcsally committed Feb 9, 2020
1 parent 0fdf322 commit e928a9d
Show file tree
Hide file tree
Showing 4 changed files with 1,222 additions and 3 deletions.
13 changes: 13 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ module.exports = {
'<rootDir>/chrome-ext/frontend/devtools.js',
'<rootDir>/chrome-ext/frontend/drawChart.js',
],
transform: { '^.+\\.jsx?$': 'babel-jest' },
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"start": "webpack -w",
"start:dev": "NODE_PATH=. NODE_ENV='development' webpack-dev-server --content-base chrome-ext/build",
"test": "NODE_PATH=. node_modules/.bin/jest",
"test": "jest",
"coveralls": "NODE_PATH=. node_modules/.bin/jest && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"build": "webpack -p",
"build:debug": "NODE_ENV=debug webpack -w"
Expand All @@ -34,6 +34,9 @@
"lodash": "4.17.14"
},
"devDependencies": {
"@babel/core": "7.8.4",
"@babel/preset-env": "7.8.4",
"babel-jest": "25.1.0",
"copy-webpack-plugin": "5.0.3",
"coveralls": "3.0.0",
"css-loader": "3.0.0",
Expand Down
Loading

0 comments on commit e928a9d

Please sign in to comment.