Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created December 6, 2016 15:04
Show Gist options
  • Save aaronmcadam/0a63a30fda52adf399a4c8d5f84a2039 to your computer and use it in GitHub Desktop.
Save aaronmcadam/0a63a30fda52adf399a4c8d5f84a2039 to your computer and use it in GitHub Desktop.
{
"presets": ["crowdlab"],
"env": {
"test": {
"plugins": [
["babel-plugin-webpack-loaders", {
"config": "${WEBPACK_CONFIG_PATH}",
"verbose": false
}]
]
}
}
}
{
...
"ava": {
"files": [
"src/**/*.test.js"
],
"babel": "inherit",
"require": [
"babel-register",
"../../tools/scripts/tests/setup-browser-env.js"
]
}
}
const chalk = require('chalk');
const path = require('path');
const shell = require('shelljs');
process.env.BABEL_DISABLE_CACHE = 1;
process.env.NODE_ENV = 'test';
process.env.WEBPACK_CONFIG_PATH = path.resolve(
__dirname,
'ava.webpack.config.js'
);
const runTests = ({ sourcePath = shell.pwd(), watch = false } = {}) => {
const module = path.basename(sourcePath.toString());
shell.cd(sourcePath);
shell.echo(chalk.cyan(`Testing ${module}...`));
shell.exec(`../../node_modules/.bin/ava -c 5 ${watch ? '--watch' : ''}`);
shell.echo('');
shell.echo(chalk.green(`Finished testing ${module}`));
};
module.exports = runTests;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment