forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec_isolation_spec.js
78 lines (64 loc) · 2.06 KB
/
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// TODO: rename this file to module_api_spec
const path = require('path')
const _ = require('lodash')
const { fs } = require('@packages/server/lib/util/fs')
const { default: systemTests } = require('../lib/system-tests')
const { STDOUT_DURATION_IN_TABLES_RE, e2ePath } = require('../lib/normalizeStdout')
const { expectCorrectModuleApiResult } = require('../lib/resultsUtils')
const { it } = systemTests
const outputPath = path.join(e2ePath, 'output.json')
const specs = [
'simple_passing.cy.js',
'simple_hooks.cy.js',
'simple_failing.cy.js',
'simple_failing_h*.cy.js', // simple failing hook spec
].join(',')
describe('e2e spec_isolation', () => {
systemTests.setup()
it('fails', {
spec: specs,
outputPath,
snapshot: false,
expectedExitCode: 5,
config: {
video: false,
},
async onRun (execFn) {
const { stdout } = await execFn()
_.each(STDOUT_DURATION_IN_TABLES_RE.exec(stdout), (str) => {
expect(str.trim(), 'spec durations in tables should not be 0ms').not.eq('0ms')
})
// now what we want to do is read in the outputPath
// and snapshot it so its what we expect after normalizing it
let json = await fs.readJsonAsync(outputPath)
json.runs = systemTests.normalizeRuns(json.runs)
// also mutates into normalized obj ready for snapshot
expectCorrectModuleApiResult(json, {
e2ePath, runs: 4, video: false,
})
systemTests.snapshot(json, { allowSharedSnapshot: true })
},
})
it('failing with retries enabled', {
spec: 'simple_failing_hook.cy.js,simple_retrying.cy.js',
outputPath,
snapshot: true,
expectedExitCode: 4,
config: {
retries: 1,
video: false,
},
async onRun (execFn) {
await execFn()
let json = await fs.readJsonAsync(outputPath)
json.runs = systemTests.normalizeRuns(json.runs)
// also mutates into normalized obj ready for snapshot
expectCorrectModuleApiResult(json, {
e2ePath,
runs: 2,
video: false,
})
systemTests.snapshot(json)
},
})
})