-
Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathrun_jest.js
More file actions
47 lines (40 loc) · 1.29 KB
/
Copy pathrun_jest.js
File metadata and controls
47 lines (40 loc) · 1.29 KB
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
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
const jestArgs = [
'--coverage',
'--coverageReporters=text',
'--coverageReporters=json-summary',
'--coverageReporters=json',
'src/observability/metrics-service.test.ts',
'src/observability/metrics-catalog.test.ts',
'src/middleware/metricsAuth.test.ts',
'src/routes/metrics.routes.test.ts',
'src/routes/metrics-validation-handler.test.ts',
'src/observability/metrics-validation.test.ts',
'src/observability/observability-config.test.ts',
'--runInBand',
'--colors=false',
];
const jestPath = path.join(__dirname, 'node_modules', '.bin', 'jest.cmd');
const child = spawn(jestPath, jestArgs, {
cwd: __dirname,
shell: false,
stdio: ['ignore', 'pipe', 'pipe'],
});
let stdout = '';
let stderr = '';
child.stdout.on('data', (data) => {
stdout += data.toString();
process.stdout.write(data);
});
child.stderr.on('data', (data) => {
stderr += data.toString();
process.stderr.write(data);
});
child.on('close', (code) => {
fs.writeFileSync(path.join(__dirname, 'jest_stdout.txt'), stdout, 'utf8');
fs.writeFileSync(path.join(__dirname, 'jest_stderr.txt'), stderr, 'utf8');
fs.writeFileSync(path.join(__dirname, 'jest_exitcode.txt'), String(code), 'utf8');
process.exit(code);
});