-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathconfig-warning.cy.ts
More file actions
206 lines (174 loc) · 8.3 KB
/
config-warning.cy.ts
File metadata and controls
206 lines (174 loc) · 8.3 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
describe('baseUrl', () => {
it('should show baseUrl warning if Cypress cannot connect to provided baseUrl', () => {
cy.scaffoldProject('config-with-base-url-warning')
cy.openProject('config-with-base-url-warning')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="alert"]').contains('Warning: Cannot Connect Base Url Warning')
cy.withCtx((ctx) => {
sinon.stub(ctx._apis.projectApi, 'isListening').resolves(undefined)
})
cy.contains('button', 'Try again').click()
cy.get('[data-cy="alert"]').should('not.exist')
})
it('should clear baseUrl warning if Cypress can connect to provided baseUrl', () => {
cy.scaffoldProject('config-with-base-url-warning')
cy.openProject('config-with-base-url-warning')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('[data-cy="alert"]').contains('Warning: Cannot Connect Base Url Warning')
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', `
module.exports = {
e2e: {
supportFile: false,
baseUrl: 'http://localhost:5555',
},
}
`)
})
cy.get('h1').should('contain', 'Choose a browser')
cy.get('[data-cy="alert"]').should('not.exist')
})
it('should add baseUrl warning when going from good to bad config', () => {
cy.scaffoldProject('config-with-js')
cy.openProject('config-with-js')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.get('h1').should('contain', 'Choose a browser')
cy.get('[data-cy="alert"]').should('not.exist')
cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js', `
module.exports = {
pageLoadTimeout: 10000,
e2e: {
supportFile: false,
baseUrl: 'http://localhost:9999',
defaultCommandTimeout: 500,
videoCompression: 20,
},
}
`)
})
cy.get('[data-cy="loading-spinner"]').should('be.visible')
cy.get('h1').should('contain', 'Choose a browser')
cy.get('[data-cy="alert"]').contains('Warning: Cannot Connect Base Url Warning')
})
})
describe('experimentalSingleTabRunMode', () => {
it('is a valid config for component testing', () => {
cy.scaffoldProject('experimentalSingleTabRunMode')
cy.openProject('experimentalSingleTabRunMode', ['--component', '--config-file', 'cypress-component-only.config.js'])
cy.visitLaunchpad()
cy.findByTestId('launchpad-Choose a browser')
cy.get('h1').contains('Choose a browser')
})
it('is not a valid config for e2e testing', () => {
cy.scaffoldProject('experimentalSingleTabRunMode')
cy.openProject('experimentalSingleTabRunMode')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('error-header').contains('Cypress configuration error')
cy.findByTestId('alert-body').contains('The experimentalSingleTabRunMode experiment is currently only supported for Component Testing.')
})
})
describe('experimentalOriginDependencies', () => {
it('is a valid config for e2e testing', () => {
cy.scaffoldProject('session-and-origin-e2e-specs')
cy.openProject('session-and-origin-e2e-specs')
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('launchpad-Choose a browser')
cy.get('h1').contains('Choose a browser')
})
it('is not a valid config for component testing', () => {
cy.scaffoldProject('session-and-origin-e2e-specs')
// TODO: remove config file from session-and-origin-e2e-specs project once the experimental flag is removed
cy.openProject('session-and-origin-e2e-specs', ['--config-file', 'cypress-invalid-component.config.js'])
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="component"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalOriginDependencies experiment is currently only supported for End to End Testing')
})
it('is not valid config when specified at root', () => {
cy.scaffoldProject('session-and-origin-e2e-specs')
// TODO: remove config file from session-and-origin-e2e-specs project once the experimental flag is removed
cy.openProject('session-and-origin-e2e-specs', ['--config-file', 'cypress-invalid-root.config.js'])
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalOriginDependencies experiment is currently only supported for End to End Testing')
})
})
describe('component testing dependency warnings', () => {
it('warns against outdated react and vite version', () => {
cy.scaffoldProject('component-testing-outdated-dependencies')
cy.addProject('component-testing-outdated-dependencies')
cy.openGlobalMode()
cy.visitLaunchpad()
cy.contains('component-testing-outdated-dependencies').click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.contains('a', 'Projects').click()
cy.get('[data-cy-testingtype="component"]').click()
cy.get('[data-cy="warning-alert"]', { timeout: 12000 }).should('exist')
.should('contain.text', 'Warning: Component Testing Mismatched Dependencies')
.should('contain.text', 'vite. Expected ^5.0.0 || ^6.0.0 || ^7.0.0, found 4.5.12')
.should('contain.text', 'react. Expected ^18.0.0 || ^19.0.0, found 15.6.2.')
.should('contain.text', 'react-dom. Expected ^18.0.0 || ^19.0.0 but dependency was not found.')
cy.get('.warning-markdown').find('li').should('have.length', 3)
})
it('warns against outdated vue/vite dependency', () => {
cy.scaffoldProject('outdated-deps-vue-vite')
cy.addProject('outdated-deps-vue-vite')
cy.openGlobalMode()
cy.visitLaunchpad()
cy.contains('outdated-deps-vue-vite').click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.contains('a', 'Projects').click()
cy.get('[data-cy-testingtype="component"]', { timeout: 12000 }).click()
cy.get('[data-cy="warning-alert"]', { timeout: 12000 }).should('exist')
.should('contain.text', 'Warning: Component Testing Mismatched Dependencies')
.should('contain.text', 'vite. Expected ^5.0.0 || ^6.0.0 || ^7.0.0, found 4.5.12.')
.should('contain.text', 'vue. Expected ^3.0.0, found 2.7.8.')
cy.get('.warning-markdown').find('li').should('have.length', 2)
})
it('does not show warning for project with supported dependencies', () => {
cy.scaffoldProject('vue3-webpack-ts-configured')
cy.addProject('vue3-webpack-ts-configured')
cy.openGlobalMode()
cy.visitLaunchpad()
cy.contains('vue3-webpack-ts-configured').click()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.get('a').contains('Projects').click()
cy.get('[data-cy-testingtype="component"]', { timeout: 10000 }).click()
// Wait until launch browser screen and assert warning does not exist
cy.contains('Choose a browser', { timeout: 12000 })
cy.get('[data-cy="warning-alert"]').should('not.exist')
})
it('does not show warning for project that does not require bundler to be installed', () => {
cy.scaffoldProject('next-14')
cy.openProject('next-14', ['--component'])
cy.visitLaunchpad()
cy.get('[data-cy="warning-alert"]').should('not.exist')
cy.contains('Choose a browser', { timeout: 12000 })
cy.get('[data-cy="warning-alert"]').should('not.exist')
})
})
describe('experimentalPromptCommand', () => {
it('is not a valid config for component testing', () => {
cy.scaffoldProject('experimentalPromptCommand')
cy.openProject('experimentalPromptCommand', ['--config-file', 'cypress-invalid-prompt-experiment.config.js'])
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="component"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalPromptCommand experiment is currently only supported for End to End Testing')
})
it('is not a valid config when specified at root', () => {
cy.scaffoldProject('experimentalPromptCommand')
cy.openProject('experimentalPromptCommand', ['--config-file', 'cypress-invalid-prompt-experiment-root.config.js'])
cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalPromptCommand experiment is currently only supported for End to End Testing')
})
})