-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
49 lines (47 loc) · 1.16 KB
/
test.js
File metadata and controls
49 lines (47 loc) · 1.16 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
48
49
/* eslint-disable @typescript-eslint/no-unused-vars */
const fsp = require('fs/promises');
const child_process = require('child_process');
const main = async () => {
try {
const options = {
silent: true,
};
options.listeners = {
stdout: (data) => {},
stderr: (data) => {},
};
console.log(`::debug::pwd is ${process.cwd()}`);
await new Promise((res) =>
child_process
.spawn(
'yarn',
[
'jest',
'--json',
'--outputFile=test.result.json',
'--testLocationInResults',
],
options,
)
.on('close', (code) => {
res();
})
.on('error', () => {
res();
})
.on('exit', () => {
res();
}),
);
const contentRaw = await fsp.readFile('test.result.json', {
encoding: 'utf-8',
});
const content = JSON.parse(contentRaw);
console.log(`::set-ouput name=pass::${content.success}`);
console.log(`::set-ouput name=result::${JSON.stringify(content)}`);
// return content;
} catch (e) {
console.log(`::error title=test failed`);
}
};
main();