1 | const path = require('path');
|
2 | const fs = require('fs');
|
3 | const setup = require('./test-setup');
|
4 | const root = process.cwd();
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | module.exports = function (config) {
|
14 | const packageJsonPath = path.resolve(root, 'package.json');
|
15 | if (!fs.existsSync(packageJsonPath)) { throw new Error('Unable to find package.json file for this package.'); }
|
16 | const { name } = require(packageJsonPath);
|
17 | config = {
|
18 | name,
|
19 | include: [],
|
20 | ...config,
|
21 | };
|
22 | return function () {
|
23 | return {
|
24 | name: config.name,
|
25 | files: [
|
26 | { pattern: 'package.json', load: false },
|
27 | '!src/**/*.tests.ts?(x)',
|
28 | { pattern: 'src/**/*.ts?(x)', load: false },
|
29 | ...config.include,
|
30 | ],
|
31 | tests: [
|
32 | { pattern: 'src/**/*.tests.ts?(x)' },
|
33 | ],
|
34 | testFramework: 'mocha',
|
35 | env: {
|
36 | type: 'node',
|
37 | },
|
38 | workers: {
|
39 | initial: 6,
|
40 | regular: 3,
|
41 | },
|
42 | debug: true,
|
43 | setup: eval('(function () { (' + setup.toString() + ')(' + JSON.stringify(config) + '); })'),
|
44 | };
|
45 | };
|
46 | };
|