-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathtest.ts
31 lines (26 loc) · 895 Bytes
/
test.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
import { join } from 'path';
import { spawn } from 'child_process';
import chalk from 'chalk';
const StaticServer = require('static-server');
const port = 5122;
const setupMockServers = () =>
new Promise(resolve => {
const server = new StaticServer({
rootPath: join(process.cwd(), 'packages', 'guess-webpack', 'test', 'fixtures'),
port
});
server.start(() => {
console.log(chalk.yellow('Test server started on port', server.port));
resolve(server);
});
});
async function main() {
await setupMockServers();
const options = process.argv.filter(a => a === '--watch');
const jest = spawn(`${process.cwd()}/node_modules/.bin/jest`, options, { stdio: 'inherit' });
return new Promise<number>(resolve => {
jest.on('exit', code => resolve(code));
jest.on('close', code => resolve(code));
});
}
main().then(code => process.exit(code));