/
5_spec_isolation_spec.js
63 lines (52 loc) · 1.73 KB
/
5_spec_isolation_spec.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// TODO: rename this file to 5_module_api_spec
const path = require('path')
const snapshot = require('snap-shot-it')
const fs = require('../../lib/util/fs')
const e2e = require('../support/helpers/e2e').default
const Fixtures = require('../support/helpers/fixtures')
const { expectCorrectModuleApiResult } = require('../support/helpers/resultsUtils')
const e2ePath = Fixtures.projectPath('e2e')
const it = e2e.it
const outputPath = path.join(e2ePath, 'output.json')
const specs = [
'simple_passing_spec.coffee',
'simple_hooks_spec.coffee',
'simple_failing_spec.coffee',
'simple_failing_h*_spec.coffee', // simple failing hook spec
].join(',')
describe('e2e spec_isolation', () => {
e2e.setup()
it('fails', {
spec: specs,
outputPath,
snapshot: false,
expectedExitCode: 5,
async onRun (exec) {
await exec()
// now what we want to do is read in the outputPath
// and snapshot it so its what we expect after normalizing it
const json = await fs.readJsonAsync(outputPath)
// also mutates into normalized obj ready for snapshot
expectCorrectModuleApiResult(json, {
e2ePath, runs: 4,
})
snapshot('e2e spec isolation fails', json, { allowSharedSnapshot: true })
},
})
it('failing with retries enabled', {
spec: 'simple_failing_hook_spec.coffee,simple_retrying_spec.js',
outputPath,
snapshot: true,
expectedExitCode: 4,
config: {
retries: 1,
},
async onRun (execFn) {
await execFn()
const json = await fs.readJsonAsync(outputPath)
// also mutates into normalized obj ready for snapshot
expectCorrectModuleApiResult(json, { e2ePath, runs: 2 })
snapshot('failing with retries enabled', json)
},
})
})