|
1 |
| -const fs = require( 'fs' ) |
2 |
| -const { extractModuleLineAndColumn } = require('mocha-json-streamier-reporter/lib/parse-stack-trace') |
3 |
| -var core = require('@actions/core'); |
4 |
| -var { issueCommand } = require('@actions/core/lib/command'); |
| 1 | +const fs = require( 'fs' ); |
| 2 | +const { |
| 3 | + extractModuleLineAndColumn |
| 4 | +} = require( 'mocha-json-streamier-reporter/lib/parse-stack-trace' ); |
| 5 | +const core = require( '@actions/core' ); |
| 6 | +const { issueCommand } = require( '@actions/core/lib/command' ); |
5 | 7 |
|
6 |
| -const suiteName = process.argv[2]; |
| 8 | +const suiteName = process.argv[ 2 ]; |
7 | 9 |
|
8 |
| -if( suiteName ) { |
9 |
| - return; |
| 10 | +if ( suiteName ) { |
| 11 | + return; |
10 | 12 | }
|
11 | 13 |
|
12 |
| -const filePath = `../../test/suites/${suiteName}/results/result.json`; |
13 |
| - |
14 |
| -var resultObject = {}; |
15 |
| - |
16 |
| -if (fs.existsSync(filePath)) { |
17 |
| - resultObject = JSON.parse(fs.readFileSync(filePath, 'utf8'))[suiteName]; |
18 |
| - |
19 |
| - if (resultObject.fail.length != 0) { |
20 |
| - |
21 |
| - resultObject.fail.forEach(test => { |
22 |
| - const error = extractModuleLineAndColumn(test.error.stack); |
23 |
| - let filePath = ''; |
24 |
| - if( error.file ) { |
25 |
| - filePath = error.file.replace('/usr/src/app/', 'test/'); |
26 |
| - } |
27 |
| - const message = test.fullTitle + ": " + test.error.message; |
28 |
| - |
29 |
| - issueCommand('error', { |
30 |
| - file: filePath, |
31 |
| - line: error.line, |
32 |
| - col: error.column |
33 |
| - }, message); |
34 |
| - }); |
35 |
| - |
36 |
| - } else { |
37 |
| - resultObject.pass.forEach(test => { |
38 |
| - core.info( 'OK: ' + test.fullTitle ); |
39 |
| - }); |
40 |
| - |
41 |
| - resultObject.skip.forEach(test => { |
42 |
| - core.warning( 'SKIP: ' + test.fullTitle ); |
43 |
| - }); |
44 |
| - |
45 |
| - core.info('\u001b[1mAll good 👍') |
46 |
| - } |
| 14 | +const filePath = `../../test/suites/${ suiteName }/results/result.json`; |
| 15 | + |
| 16 | +let resultObject = {}; |
| 17 | + |
| 18 | +if ( fs.existsSync( filePath ) ) { |
| 19 | + resultObject = JSON.parse( fs.readFileSync( filePath, 'utf8' ) )[ suiteName ]; |
| 20 | + |
| 21 | + if ( resultObject.fail.length != 0 ) { |
| 22 | + resultObject.fail.forEach( ( test ) => { |
| 23 | + const error = extractModuleLineAndColumn( test.error.stack ); |
| 24 | + let filePath = ''; |
| 25 | + if ( error.file ) { |
| 26 | + filePath = error.file.replace( '/usr/src/app/', 'test/' ); |
| 27 | + } |
| 28 | + const message = test.fullTitle + ': ' + test.error.message; |
| 29 | + |
| 30 | + issueCommand( |
| 31 | + 'error', |
| 32 | + { |
| 33 | + file: filePath, |
| 34 | + line: error.line, |
| 35 | + col: error.column |
| 36 | + }, |
| 37 | + message |
| 38 | + ); |
| 39 | + } ); |
| 40 | + } else { |
| 41 | + resultObject.pass.forEach( ( test ) => { |
| 42 | + core.info( 'OK: ' + test.fullTitle ); |
| 43 | + } ); |
| 44 | + |
| 45 | + resultObject.skip.forEach( ( test ) => { |
| 46 | + core.warning( 'SKIP: ' + test.fullTitle ); |
| 47 | + } ); |
| 48 | + |
| 49 | + core.info( '\u001b[1mAll good 👍' ); |
| 50 | + } |
47 | 51 | } else {
|
48 |
| - core.error('No tests executed!'); |
| 52 | + core.error( 'No tests executed!' ); |
49 | 53 | }
|
0 commit comments