-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest.ts
More file actions
36 lines (31 loc) · 881 Bytes
/
test.ts
File metadata and controls
36 lines (31 loc) · 881 Bytes
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
import { build } from './build.ts';
import { run } from './util.ts';
export async function test(opts: { local: boolean; ci: boolean; args: string[] }): Promise<void> {
const jestArgs = ['--runInBand', ...(opts.ci ? ['--ci'] : []), ...opts.args];
if (opts.local) {
await testLocal({ args: jestArgs });
} else {
await testDocker({ ci: opts.ci, args: jestArgs });
}
}
async function testLocal(opts: { args: string[] }): Promise<void> {
run('npx', ['jest', ...opts.args]);
}
async function testDocker(opts: { ci: boolean; args: string[] }): Promise<void> {
await build.image();
const cwd = process.cwd();
const dockerArgs = [
'run',
'--rm',
opts.ci ? '-i' : '-it',
'-v',
`${cwd}/src:/vexml/src`,
'-v',
`${cwd}/tests:/vexml/tests`,
'vexml:latest',
'npx',
'jest',
...opts.args,
];
run('docker', dockerArgs);
}