forked from TypeStrong/ts-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ava.config.cjs
40 lines (34 loc) · 1.31 KB
/
ava.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const expect = require('expect');
const { createRequire } = require('module');
module.exports = {
files: ['dist/test/**/*.spec.js'],
failWithoutAssertions: false,
environmentVariables: {
ts_node_install_lock: `id-${Math.floor(Math.random() * 10e9)}`,
// Force jest expect() errors to generate colorized strings, makes output more readable.
// Delete the env var within ava processes via `require` option below.
// This avoids passing it to spawned processes under test, which would negatively affect
// their behavior.
FORCE_COLOR: '3',
},
require: ['./src/test/remove-env-var-force-color.js'],
timeout: '300s',
concurrency: 1,
};
{
/*
* Tests *must* install and use our most recent ts-node tarball.
* We must prevent them from accidentally require-ing a different version of
* ts-node, from either node_modules or tests/node_modules
*/
const { existsSync } = require('fs');
const rimraf = require('rimraf');
const { resolve } = require('path');
remove(resolve(__dirname, 'node_modules/ts-node'));
remove(resolve(__dirname, 'tests/node_modules/ts-node'));
// Prove that we did it correctly
expect(() => {createRequire(resolve(__dirname, 'tests/foo.js')).resolve('ts-node')}).toThrow();
function remove(p) {
if(existsSync(p)) rimraf.sync(p, {recursive: true})
}
}