Skip to content

Commit

Permalink
fix(jest): resolve babel-jest error
Browse files Browse the repository at this point in the history
Jest does not have proper support for setups that use both a .babelrc and .babelrc.js file as it throws babel errors when you have both. The fix must be made in babel-jest, until then we can use a fork so that atleast jest will function
  • Loading branch information
JeroenVinke committed Aug 24, 2017
1 parent b6133e5 commit 3cfd956
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"awesome-typescript-loader": "^3.2.1",
"babel-core": "^6.25.0",
"babel-eslint": "^6.0.4",
"babel-jest": "^20.0.3",
"babel-jest": "github:JeroenVinke/babel-jest",
"babel-loader": "^7.0.0",
"babel-plugin-istanbul": "4.1.4",
"babel-plugin-syntax-flow": "^6.8.0",
Expand Down
46 changes: 24 additions & 22 deletions lib/resources/content/babelrc.webpack.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
// this file will be used by default by babel@7 once it is released
module.exports = {
"plugins": [
"transform-decorators-legacy",
"transform-class-properties"
],
"presets": [
[
"env", {
"targets": process.env.BABEL_TARGET === 'node' ? {
"node": process.env.IN_PROTRACTOR ? '6' : 'current'
} : {
"browsers": [
"last 2 versions",
"not ie <= 11"
],
"uglify": process.env.NODE_ENV === 'production',
},
"loose": true,
"modules": process.env.BABEL_TARGET === 'node' ? 'commonjs' : false,
"useBuiltIns": true
}
module.exports = () => {
return {
"plugins": [
"transform-decorators-legacy",
"transform-class-properties"
],
"presets": [
[
"env", {
"targets": process.env.BABEL_TARGET === 'node' ? {
"node": process.env.IN_PROTRACTOR ? '6' : 'current'
} : {
"browsers": [
"last 2 versions",
"not ie <= 11"
],
"uglify": process.env.NODE_ENV === 'production',
},
"loose": true,
"modules": process.env.BABEL_TARGET === 'node' ? 'commonjs' : false,
"useBuiltIns": true
}
]
]
]
}
}
9 changes: 5 additions & 4 deletions lib/resources/tasks/jest.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import jest from 'jest-cli';
import gutil from 'gulp-util';
import through2 from 'through2';
import path from 'path';
import packageJson from '../../package.json';
import {CLIOptions} from 'aurelia-cli';

export default (cb) => {
let options = packageJson.jest;

if (CLIOptions.hasFlag('watch')) {
Object.assign(options, { watch: true});
}

process.env.BABEL_TARGET = 'node';

jest.runCLI(options, [path.resolve(__dirname, '../../')], (result) => {
if(result.numFailedTests || result.numFailedTestSuites) {
if (result.numFailedTests || result.numFailedTestSuites) {
cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' }));
} else {
cb();
}
});
};
};

0 comments on commit 3cfd956

Please sign in to comment.