-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
test-argv.ts
31 lines (26 loc) · 987 Bytes
/
test-argv.ts
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
// the arguments when running test files, abstracted from run.ts for testing
import type { LoadedConfig } from '@tapjs/config'
import { importLoaders, loaderFallbacks, loaders } from '@tapjs/test'
import module from 'node:module'
// if we have Module.register(), then use --import wherever possible
const useImport = !!(module as { register?: (...a: any) => any })
.register
const importScripts = useImport ? importLoaders : []
const loaderScripts = useImport ? loaders : loaderFallbacks
const pi = useImport
? '--import=@tapjs/processinfo/import'
: '--loader=@tapjs/processinfo/loader'
const always = [
...importScripts.map(l => `--import=${l}`),
...loaderScripts.map(l => `--loader=${l}`),
...(useImport && !loaderScripts.length
? []
: ['--no-warnings=ExperimentalLoader']),
'--enable-source-maps',
// ensure this always comes last in the list
pi,
]
export const testArgv = (config: LoadedConfig) => [
...always,
...(config.get('node-arg') || []),
]