2021-09-12 20:44:30 +03:00
|
|
|
const path = require('path');
|
2023-08-29 23:18:37 +03:00
|
|
|
const minimist = require('minimist');
|
2020-10-30 09:27:41 +03:00
|
|
|
|
2023-08-29 23:18:37 +03:00
|
|
|
const {
|
|
|
|
_: [_node, _mocha, ...args], // _ contains the node binary, the mocha binary, and any positional args
|
|
|
|
...flags
|
|
|
|
} = minimist(process.argv);
|
|
|
|
|
|
|
|
process.env.LINK_FORGE_DEPENDENCIES_ON_INIT = true;
|
|
|
|
|
|
|
|
let testGlob;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine which sets of tests to run. Priority goes:
|
|
|
|
* 1. If positional arguments are passed in, run those files.
|
|
|
|
* 2. If `--suite` is either slow or fast, run slow or fast test.
|
|
|
|
* 3. Otherwise, run all spec tests.
|
|
|
|
*/
|
|
|
|
if (args.length === 0) {
|
|
|
|
if (flags.suite === 'fast') {
|
|
|
|
testGlob = 'packages/**/*_spec.ts';
|
|
|
|
} else if (flags.suite === 'slow') {
|
|
|
|
testGlob = 'packages/**/*_spec_slow.ts';
|
|
|
|
} else {
|
|
|
|
testGlob = 'packages/**/**/*_spec*';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// In CI, use the JUnit reporter to upload results to CircleCI.
|
|
|
|
// Locally, use the default 'spec' reporter.
|
2023-08-23 20:26:26 +03:00
|
|
|
const reporterConfig = process.env.CI
|
|
|
|
? {
|
|
|
|
reporter: 'mocha-junit-reporter',
|
|
|
|
'reporter-option': ['mochaFile=./reports/test_output.xml'],
|
|
|
|
}
|
|
|
|
: {};
|
|
|
|
|
2023-08-29 23:18:37 +03:00
|
|
|
const opts = {
|
2022-02-27 11:19:44 +03:00
|
|
|
extension: ['ts'],
|
2022-05-03 20:29:31 +03:00
|
|
|
require: ['ts-node/register', path.join(__dirname, 'tools', 'test-setup.ts')],
|
2023-08-29 23:18:37 +03:00
|
|
|
spec: testGlob,
|
2021-09-12 20:44:30 +03:00
|
|
|
timeout: 800000,
|
|
|
|
recursive: true,
|
2023-08-23 20:26:26 +03:00
|
|
|
...reporterConfig,
|
2021-09-12 20:44:30 +03:00
|
|
|
};
|
2023-08-29 23:18:37 +03:00
|
|
|
|
|
|
|
module.exports = opts;
|