test: specific
This commit is contained in:
parent
e7511e7ee4
commit
4bed4730b9
|
@ -17,6 +17,9 @@ const {
|
||||||
module.exports = (program, flecks) => {
|
module.exports = (program, flecks) => {
|
||||||
const commands = {};
|
const commands = {};
|
||||||
commands.test = {
|
commands.test = {
|
||||||
|
args: [
|
||||||
|
program.createArgument('[only]', 'only run a specific test'),
|
||||||
|
],
|
||||||
options: [
|
options: [
|
||||||
program.createOption('-d, --no-production', 'dev build'),
|
program.createOption('-d, --no-production', 'dev build'),
|
||||||
program.createOption('-t, --timeout <ms>', 'timeout').default(2000),
|
program.createOption('-t, --timeout <ms>', 'timeout').default(2000),
|
||||||
|
@ -28,7 +31,7 @@ module.exports = (program, flecks) => {
|
||||||
'',
|
'',
|
||||||
'The options are passed along to the `build` command.',
|
'The options are passed along to the `build` command.',
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
action: async (opts) => {
|
action: async (only, opts) => {
|
||||||
const {
|
const {
|
||||||
timeout,
|
timeout,
|
||||||
watch,
|
watch,
|
||||||
|
@ -36,11 +39,23 @@ module.exports = (program, flecks) => {
|
||||||
const {build} = coreCommands(program, flecks);
|
const {build} = coreCommands(program, flecks);
|
||||||
const tests = await glob(join(FLECKS_CORE_ROOT, 'test', '*.js'));
|
const tests = await glob(join(FLECKS_CORE_ROOT, 'test', '*.js'));
|
||||||
const serverTests = await glob(join(FLECKS_CORE_ROOT, 'test', 'server', '*.js'));
|
const serverTests = await glob(join(FLECKS_CORE_ROOT, 'test', 'server', '*.js'));
|
||||||
if (0 === tests.length + serverTests.length) {
|
let files = []
|
||||||
|
.concat(tests, serverTests)
|
||||||
|
.map((path) => relative(FLECKS_CORE_ROOT, path));
|
||||||
|
if (0 === files.length) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('No tests found.');
|
console.log('No tests found.');
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
if (only) {
|
||||||
|
if (files.includes(only)) {
|
||||||
|
files = [only];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(`Test '${only}' does not exist!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
files = files.map((file) => join('dist', file));
|
||||||
// Remove the previous test.
|
// Remove the previous test.
|
||||||
await rimraf(join(FLECKS_CORE_ROOT, 'dist', 'test'));
|
await rimraf(join(FLECKS_CORE_ROOT, 'dist', 'test'));
|
||||||
// Kick off building the test and wait for the file to exist.
|
// Kick off building the test and wait for the file to exist.
|
||||||
|
@ -70,9 +85,6 @@ module.exports = (program, flecks) => {
|
||||||
);
|
);
|
||||||
const mocha = new Mocha({parallel: true, timeout});
|
const mocha = new Mocha({parallel: true, timeout});
|
||||||
mocha.ui('bdd');
|
mocha.ui('bdd');
|
||||||
const files = []
|
|
||||||
.concat(tests, serverTests)
|
|
||||||
.map((path) => join('dist', relative(FLECKS_CORE_ROOT, path)));
|
|
||||||
if (watch) {
|
if (watch) {
|
||||||
watchParallelRun(
|
watchParallelRun(
|
||||||
mocha,
|
mocha,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user