-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): Add more testing features
Add ability to run without coverage, add ability to run without cache, have mastarm control babel transformation instead of requiring projects to define a .babelrc file.
- Loading branch information
1 parent
b47a0a9
commit b9ef80e
Showing
4 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const babel = require('babel-core') | ||
const jestPreset = require('babel-preset-jest') | ||
|
||
module.exports = { | ||
process: function (src) { | ||
const transformCfg = { | ||
presets: ['es2015', 'react', 'stage-0', jestPreset] | ||
} | ||
return babel.transform(src, transformCfg).code | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
const path = require('path') | ||
|
||
module.exports = function generateTestConfig (config, options) { | ||
if (config.messages) { | ||
process.env.MESSAGES = JSON.stringify(config.messages) | ||
} | ||
module.exports.generateTestConfig = (options) => { | ||
const jestConfig = { | ||
collectCoverage: true, | ||
collectCoverage: options.coverage, | ||
collectCoverageFrom: ['lib/**/*.js'], | ||
coverageDirectory: 'coverage' | ||
coverageDirectory: 'coverage', | ||
scriptPreprocessor: path.resolve(__dirname, 'jestPreprocessor.js') | ||
} | ||
const jestArguments = [] | ||
if (options.updateSnapshots) { | ||
jestArguments.push('-u') | ||
} | ||
if (options.cache === false) { | ||
jestArguments.push('--no-cache') | ||
} | ||
jestArguments.push('--config', JSON.stringify(jestConfig)) | ||
return jestArguments | ||
} | ||
|
||
module.exports.setupTestEnvironment = (config) => { | ||
if (config.messages) { | ||
process.env.MESSAGES = JSON.stringify(config.messages) | ||
} | ||
} |