-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathissue_8280_spec.js
More file actions
92 lines (73 loc) · 3.11 KB
/
issue_8280_spec.js
File metadata and controls
92 lines (73 loc) · 3.11 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const { fs } = require('@packages/server/lib/util/fs')
const Fixtures = require('../lib/fixtures')
const systemTests = require('../lib/system-tests').default
const PROJECT_NAME = 'issue-8280-retain-video'
describe('e2e issue 8280', () => {
systemTests.setup()
// https://github.com/cypress-io/cypress/issues/8280
it('should retain the videos from previous runs if trashAssetsBeforeRuns=false', async function () {
// first run
await systemTests.exec(this, {
project: PROJECT_NAME,
snapshot: false,
expectedExitCode: 2,
processEnv: {
'CYPRESS_trashAssetsBeforeRuns': 'false',
},
})
// second run
await systemTests.exec(this, {
project: PROJECT_NAME,
snapshot: false,
expectedExitCode: 2,
processEnv: {
'CYPRESS_trashAssetsBeforeRuns': 'false',
},
})
const spec1Screenshots = await fs.readdir(Fixtures.projectPath(`${PROJECT_NAME}/cypress/screenshots/spec1.cy.js`))
expect(spec1Screenshots.length).to.eq(2)
expect(spec1Screenshots).to.include('spec1 -- testCase1 (failed).png')
expect(spec1Screenshots).to.include('spec1 -- testCase1 (failed) (1).png')
const spec2Screenshots = await fs.readdir(Fixtures.projectPath(`${PROJECT_NAME}/cypress/screenshots/spec2.cy.js`))
expect(spec2Screenshots.length).to.eq(2)
expect(spec2Screenshots).to.include('spec2 -- testCase1 (failed).png')
expect(spec2Screenshots).to.include('spec2 -- testCase1 (failed) (1).png')
const videos = await fs.readdir(Fixtures.projectPath(`${PROJECT_NAME}/cypress/videos`))
expect(videos.length).to.eq(4)
expect(videos).to.include('spec1.cy.js.mp4')
expect(videos).to.include('spec1.cy.js (1).mp4')
expect(videos).to.include('spec2.cy.js.mp4')
expect(videos).to.include('spec2.cy.js (1).mp4')
})
// if trash assets = true, then there will be no retention of screenshots or videos
it('should not retain the videos from previous runs if trashAssetsBeforeRuns=true', async function () {
// first run
await systemTests.exec(this, {
project: PROJECT_NAME,
snapshot: false,
expectedExitCode: 2,
processEnv: {
'CYPRESS_trashAssetsBeforeRuns': 'true',
},
})
// second run
await systemTests.exec(this, {
project: PROJECT_NAME,
snapshot: false,
expectedExitCode: 2,
processEnv: {
'CYPRESS_trashAssetsBeforeRuns': 'true',
},
})
const spec1Screenshots = await fs.readdir(Fixtures.projectPath(`${PROJECT_NAME}/cypress/screenshots/spec1.cy.js`))
expect(spec1Screenshots.length).to.eq(1)
expect(spec1Screenshots).to.include('spec1 -- testCase1 (failed).png')
const spec2Screenshots = await fs.readdir(Fixtures.projectPath(`${PROJECT_NAME}/cypress/screenshots/spec2.cy.js`))
expect(spec2Screenshots.length).to.eq(1)
expect(spec2Screenshots).to.include('spec2 -- testCase1 (failed).png')
const videos = await fs.readdir(Fixtures.projectPath(`${PROJECT_NAME}/cypress/videos`))
expect(videos.length).to.eq(2)
expect(videos).to.include('spec1.cy.js.mp4')
expect(videos).to.include('spec2.cy.js.mp4')
})
})