Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config,
runInBand,
projects: [rootDir],
}
if (testPatterns.length > 0) {
jestOptions.testPathPattern = testPatterns
.map(it => it.endsWith(".js") || it.endsWith("*") ? it : `${it}\\.js$`)
}
if (process.env.CIRCLECI != null || process.env.TEST_JUNIT_REPORT === "true") {
jestOptions.reporters = ["default", "jest-junit"]
}
// console.log(JSON.stringify(jestOptions, null, 2))
const testResult = await require("jest-cli").runCLI(jestOptions, jestOptions.projects)
const exitCode = testResult.results == null || testResult.results.success ? 0 : testResult.globalConfig.testFailureExitCode
if (isCi) {
process.exit(exitCode)
}
await remove(APP_BUILDER_TMP_DIR)
process.exitCode = exitCode
if (testResult.globalConfig.forceExit) {
process.exit(exitCode)
}
}
*/
/* eslint-disable no-console */
const jestCLI = require('jest-cli');
const config = require('../jest.config.js');
const yargs = require('yargs');
const {options} = require('jest-cli/build/cli/args');
// We reach into the internals of Jest to get the options it uses for arg
// parsing with yargs to ensure we parse the args consistently with Jest.
const {argv} = yargs(process.argv.slice(2)).options(options);
// Then we override some of the options with hardcoded values.
argv.watchman = true;
argv.config = JSON.stringify(config);
jestCLI
.runCLI(argv, [process.cwd()])
.then(response => process.exit(response.results.success ? 0 : 1));
const run = () => {
const options = {
roots: ["__checks__"],
verbose: true,
testPathIgnorePatterns: []
};
jest.runCLI(options, [__dirname]).then(({ results }) => {
if (!results.success) {
process.exit(1);
}
});
};
gulp.task('test', function(callback) {
gulp.watch('__tests__/**/*.js', ['test']);
gulp.watch('scripts/**/*.js', ['test']);
var onComplete = function() {
callback();
};
jest.runCLI({}, __dirname, onComplete);
});
grunt.registerTask('jest', 'Run tests with Jest.', function() {
require('jest-cli').runCLI(this.options(), process.cwd(), this.async());
});
export default (cb) => {
let options = packageJson.jest;
if (CLIOptions.hasFlag('watch')) {
Object.assign(options, { watch: true});
}
jest.runCLI(options, [path.resolve(__dirname, '../../')]).then((result) => {
if(result.numFailedTests || result.numFailedTestSuites) {
cb(new PluginError('gulp-jest', { message: 'Tests Failed' }));
} else {
cb();
}
});
};
export default (cb) => {
let options = packageJson.jest;
if (CLIOptions.hasFlag('watch')) {
Object.assign(options, { watch: true });
}
jest.runCLI(options, [path.resolve(__dirname, '../../')], (result) => {
if (result.numFailedTests || result.numFailedTestSuites) {
cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' }));
} else {
cb();
}
});
};
module.exports = function(callback) {
jest.runCLI({ config: jestConfig }, configs.paths.source, function(result) {
if (!result || !result.success) {
callback('Jest tests failed');
} else {
callback();
}
});
};
module.exports = async ({ config, projects = [process.cwd()] }) => {
const argv = {
config: JSON.stringify(config),
};
const { results } = await runCLI(argv, projects);
if (!results.success) {
throw new Error(`Jest failed with ${results.numFailedTests} failing tests`);
}
return results;
};
return function jest(done) {
const onComplete = (runResults) => {
if (runResults.success === false && failAfterError === true) {
done(new Error('[jest] at least 1 test failed'));
} else {
done();
}
};
jestCli.runCLI({ config }, root, onComplete);
};
}