mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Update Jest script to output coverage * kill console.log
This commit is contained in:
parent
93c61fcb4e
commit
b4d200c172
1 changed files with 30 additions and 9 deletions
|
@ -12,19 +12,43 @@ const { runXPackScript } = require('./_helpers');
|
|||
// we're making this script allow
|
||||
run(
|
||||
({ log, flags }) => {
|
||||
const { all, storybook, update } = flags;
|
||||
const { all, storybook, update, coverage } = flags;
|
||||
let { path } = flags;
|
||||
let options = [];
|
||||
process.argv.splice(2, process.argv.length - 2);
|
||||
|
||||
if (!path) {
|
||||
if (path) {
|
||||
log.info(`Limiting tests to ${path}...`);
|
||||
path = 'legacy/plugins/canvas/' + path;
|
||||
} else {
|
||||
path = 'legacy/plugins/canvas';
|
||||
}
|
||||
|
||||
if (coverage) {
|
||||
log.info(`Collecting test coverage and writing to canvas/coverage...`);
|
||||
options = [
|
||||
'--coverage',
|
||||
'--collectCoverageFrom', // Ignore TS definition files
|
||||
`!${path}/**/*.d.ts`,
|
||||
'--collectCoverageFrom', // Ignore build directories
|
||||
`!${path}/**/build/**`,
|
||||
'--collectCoverageFrom', // Ignore coverage on test files
|
||||
`!${path}/**/__tests__/**/*`,
|
||||
'--collectCoverageFrom', // Include JS files
|
||||
`${path}/**/*.js`,
|
||||
'--collectCoverageFrom', // Include TS/X files
|
||||
`${path}/**/*.ts*`,
|
||||
'--coverageDirectory', // Output to canvas/coverage
|
||||
'legacy/plugins/canvas/coverage',
|
||||
];
|
||||
} else {
|
||||
// Mitigation for https://github.com/facebook/jest/issues/7267
|
||||
if (all || storybook || update) {
|
||||
options = ['--no-cache', '--no-watchman'];
|
||||
options = options.concat(['--no-cache', '--no-watchman']);
|
||||
}
|
||||
|
||||
if (all) {
|
||||
log.info('Running all available tests. This will take a while...');
|
||||
path = 'legacy/plugins/canvas';
|
||||
} else if (storybook || update) {
|
||||
path = 'legacy/plugins/canvas/.storybook';
|
||||
|
||||
|
@ -36,13 +60,9 @@ run(
|
|||
}
|
||||
} else {
|
||||
log.info('Running tests. This does not include Storybook Snapshots...');
|
||||
path = 'legacy/plugins/canvas';
|
||||
}
|
||||
} else {
|
||||
log.info(`Running tests found at ${path}...`);
|
||||
}
|
||||
|
||||
process.argv.splice(2, process.argv.length - 2);
|
||||
runXPackScript('jest', [path].concat(options));
|
||||
},
|
||||
{
|
||||
|
@ -50,13 +70,14 @@ run(
|
|||
Jest test runner for Canvas. By default, will not include Storybook Snapshots.
|
||||
`,
|
||||
flags: {
|
||||
boolean: ['all', 'storybook', 'update'],
|
||||
boolean: ['all', 'storybook', 'update', 'coverage'],
|
||||
string: ['path'],
|
||||
help: `
|
||||
--all Runs all tests and snapshots. Slower.
|
||||
--storybook Runs Storybook Snapshot tests only.
|
||||
--update Updates Storybook Snapshot tests.
|
||||
--path <string> Runs any tests at a given path.
|
||||
--coverage Collect coverage statistics.
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue