Skip to content

Commit e039fbd

Browse files
authored
Add messages for browser test processes (#53)
* Add messages for browser test processes * Exclude tests from build
1 parent 5ca5189 commit e039fbd

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

src/bin/testProcess.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { spawn, spawnSync, SpawnSyncOptions } from 'child_process'
22
import { readConfig } from '../utils'
3-
import { checkBrowsers } from './utils'
3+
import { checkBrowsers, getResultByStatus } from './utils'
44
import { PARALLEL, BrowserType } from '../constants'
55

66
const getSpawnOptions = (browser: BrowserType): SpawnSyncOptions => ({
@@ -21,12 +21,19 @@ const exec = ({
2121
browser: BrowserType
2222
params: string[]
2323
}): void => {
24-
// TODO Add messages for browser process
2524
const options = getSpawnOptions(browser)
2625
if (sequence === PARALLEL) {
27-
spawn('node', [`node_modules/.bin/jest ${params}`], options)
26+
const process = spawn('node', [`node_modules/.bin/jest ${params}`], options)
27+
process.on('close', status => {
28+
console.log(`${getResultByStatus(status)} tests for ${browser}\n\n`)
29+
})
2830
} else {
29-
spawnSync('node', [`node_modules/.bin/jest ${params}`], options)
31+
const { status } = spawnSync(
32+
'node',
33+
[`node_modules/.bin/jest ${params}`],
34+
options,
35+
)
36+
console.log(`${getResultByStatus(status)} tests for ${browser}`)
3037
}
3138
}
3239

src/bin/utils.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { checkBrowsers } from './utils'
1+
import { checkBrowsers, getResultByStatus } from './utils'
22
import { BrowserType } from '../constants'
33

44
describe('checkBrowsers', () => {
@@ -18,3 +18,17 @@ describe('checkBrowsers', () => {
1818
).toThrow()
1919
})
2020
})
21+
22+
describe('getResultByStatus', () => {
23+
it('should return "Failed" if passed null', () => {
24+
expect(getResultByStatus(null)).toBe('Failed')
25+
})
26+
27+
it('should return "Failed" if passed code 1', () => {
28+
expect(getResultByStatus(1)).toBe('Failed')
29+
})
30+
31+
it('should return "Passed" if passed code 0', () => {
32+
expect(getResultByStatus(0)).toBe('Passed')
33+
})
34+
})

src/bin/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export const checkBrowsers = (browsers?: BrowserType[]): void => {
99
}
1010
browsers.forEach(checkBrowserEnv)
1111
}
12+
13+
export const getResultByStatus = (status: number | null): string => {
14+
return status !== 0 ? 'Failed' : 'Passed'
15+
}

tsconfig.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
"forceConsistentCasingInFileNames": true
99
},
1010
"files": [
11-
"types/global.d.ts",
11+
"types/global.d.ts"
1212
],
1313
"include": [
14-
"src/**/*",
14+
"src/**/*"
1515
],
16-
}
16+
"exclude": [
17+
"node_modules",
18+
"**/*.test.ts"
19+
]
20+
}

0 commit comments

Comments
 (0)