1 | const path = require('path');
|
2 |
|
3 | function addIfExists(dependency) {
|
4 | try {
|
5 | require.resolve(dependency);
|
6 | return dependency;
|
7 | } catch (e) {
|
8 | if (e.message && e.message.toLowerCase().includes('cannot find module')) {
|
9 | return undefined;
|
10 | } else {
|
11 | throw e;
|
12 | }
|
13 | }
|
14 | }
|
15 |
|
16 | module.exports = (function () {
|
17 | const root = process.cwd();
|
18 |
|
19 | process.env['is-mocha'] = true;
|
20 | return {
|
21 | require: [
|
22 | 'ts-node/register',
|
23 | addIfExists('jsdom-global/register'),
|
24 | addIfExists('anux-common'),
|
25 | path.relative(root, path.resolve(__dirname, './test-setup.js')),
|
26 | ].filter(v => v != null),
|
27 | spec: './src/**/*.tests.+(ts|tsx)',
|
28 | };
|
29 | })();
|