-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathtest.js
54 lines (38 loc) · 1.6 KB
/
test.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import test from '@ava/test';
import {cleanOutput, cwd, fixture} from '../helpers/exec.js';
test('passed node arguments to workers', async t => {
const options = {
cwd: cwd('node-arguments'),
};
// Removed --fill-zero-buffer because not supported in worker_threads
const result = await fixture(['--node-arguments="--throw-deprecation"', 'node-arguments.js'], options);
t.snapshot(result.stats.passed, 'tests pass');
});
test('`filterNodeArgumentsForWorkerThreads` configuration filters arguments for worker thread', async t => {
const options = {
cwd: cwd('thread-arguments-filter'),
};
const result = await fixture(['--config=thread-arguments-filter.config.mjs', 'thread.js'], options);
t.snapshot(result.stats.passed, 'tests pass');
});
test('`filterNodeArgumentsForWorkerThreads` configuration ignored for worker process', async t => {
const options = {
cwd: cwd('thread-arguments-filter'),
};
const result = await fixture(['--config=thread-arguments-filter.config.mjs', '--no-worker-threads', 'process.js'], options);
t.snapshot(result.stats.passed, 'tests pass');
});
test('detects incomplete --node-arguments', async t => {
const options = {
cwd: cwd('node-arguments'),
};
const result = await t.throwsAsync(fixture(['--node-arguments="--foo=\'bar"', 'node-arguments.js'], options));
t.snapshot(cleanOutput(result.stderr), 'fails with message');
});
test('reads node arguments from config', async t => {
const options = {
cwd: cwd('node-arguments-from-config'),
};
const result = await fixture(['node-arguments-from-config.js'], options);
t.snapshot(result.stats.passed, 'tests pass');
});