Skip to content

Commit b2c895d

Browse files
authored
fix: lint errors (#802)
Fixes #661
1 parent 824fcc5 commit b2c895d

File tree

7 files changed

+108
-77
lines changed

7 files changed

+108
-77
lines changed

.eslintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
},
1515
"rules": {
1616
"indent": ["error", 2, { "SwitchCase": 1, "MemberExpression": "off" }],
17-
// TODO: remove after https://github.com/cypress-io/cypress-example-kitchensink/issues/661 has been resolved
18-
"cypress/unsafe-to-chain-command": "off",
1917
"mocha/no-exclusive-tests": "error",
2018
"mocha/no-mocha-arrows": "off"
2119
}

cypress/e2e/2-advanced-examples/actions.cy.js

Lines changed: 69 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,51 @@ context('Actions', () => {
99

1010
it('.type() - type into a DOM element', () => {
1111
// https://on.cypress.io/type
12-
cy.get('.action-email')
13-
.type('[email protected]').should('have.value', '[email protected]')
12+
cy.get('.action-email').type('[email protected]')
13+
cy.get('.action-email').should('have.value', '[email protected]')
1414

15-
// .type() with special character sequences
16-
.type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
17-
.type('{del}{selectall}{backspace}')
15+
// .type() with special character sequences
16+
cy.get('.action-email').type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
17+
cy.get('.action-email').type('{del}{selectall}{backspace}')
1818

19-
// .type() with key modifiers
20-
.type('{alt}{option}') //these are equivalent
21-
.type('{ctrl}{control}') //these are equivalent
22-
.type('{meta}{command}{cmd}') //these are equivalent
23-
.type('{shift}')
19+
// .type() with key modifiers
20+
cy.get('.action-email').type('{alt}{option}') //these are equivalent
21+
cy.get('.action-email').type('{ctrl}{control}') //these are equivalent
22+
cy.get('.action-email').type('{meta}{command}{cmd}') //these are equivalent
23+
cy.get('.action-email').type('{shift}')
2424

25-
// Delay each keypress by 0.1 sec
26-
.type('[email protected]', { delay: 100 })
27-
.should('have.value', '[email protected]')
25+
// Delay each keypress by 0.1 sec
26+
cy.get('.action-email').type('[email protected]', { delay: 100 })
27+
cy.get('.action-email').should('have.value', '[email protected]')
2828

2929
cy.get('.action-disabled')
3030
// Ignore error checking prior to type
3131
// like whether the input is visible or disabled
3232
.type('disabled error checking', { force: true })
33-
.should('have.value', 'disabled error checking')
33+
cy.get('.action-disabled').should('have.value', 'disabled error checking')
3434
})
3535

3636
it('.focus() - focus on a DOM element', () => {
3737
// https://on.cypress.io/focus
3838
cy.get('.action-focus').focus()
39-
.should('have.class', 'focus')
39+
cy.get('.action-focus').should('have.class', 'focus')
4040
.prev().should('have.attr', 'style', 'color: orange;')
4141
})
4242

4343
it('.blur() - blur off a DOM element', () => {
4444
// https://on.cypress.io/blur
45-
cy.get('.action-blur').type('About to blur').blur()
46-
.should('have.class', 'error')
45+
cy.get('.action-blur').type('About to blur')
46+
cy.get('.action-blur').blur()
47+
cy.get('.action-blur').should('have.class', 'error')
4748
.prev().should('have.attr', 'style', 'color: red;')
4849
})
4950

5051
it('.clear() - clears an input or textarea element', () => {
5152
// https://on.cypress.io/clear
5253
cy.get('.action-clear').type('Clear this text')
53-
.should('have.value', 'Clear this text')
54-
.clear()
55-
.should('have.value', '')
54+
cy.get('.action-clear').should('have.value', 'Clear this text')
55+
cy.get('.action-clear').clear()
56+
cy.get('.action-clear').should('have.value', '')
5657
})
5758

5859
it('.submit() - submit a form', () => {
@@ -61,7 +62,7 @@ context('Actions', () => {
6162
.find('[type="text"]').type('HALFOFF')
6263

6364
cy.get('.action-form').submit()
64-
.next().should('contain', 'Your form has been submitted!')
65+
cy.get('.action-form').next().should('contain', 'Your form has been submitted!')
6566
})
6667

6768
it('.click() - click on a DOM element', () => {
@@ -97,13 +98,13 @@ context('Actions', () => {
9798
// that controls where the click occurs :)
9899

99100
cy.get('#action-canvas')
100-
.click(80, 75) // click 80px on x coord and 75px on y coord
101-
.click(170, 75)
102-
.click(80, 165)
103-
.click(100, 185)
104-
.click(125, 190)
105-
.click(150, 185)
106-
.click(170, 165)
101+
cy.get('#action-canvas').click(80, 75) // click 80px on x coord and 75px on y coord
102+
cy.get('#action-canvas').click(170, 75)
103+
cy.get('#action-canvas').click(80, 165)
104+
cy.get('#action-canvas').click(100, 185)
105+
cy.get('#action-canvas').click(125, 190)
106+
cy.get('#action-canvas').click(150, 185)
107+
cy.get('#action-canvas').click(170, 165)
107108

108109
// click multiple elements by passing multiple: true
109110
cy.get('.action-labels>.label').click({ multiple: true })
@@ -117,7 +118,8 @@ context('Actions', () => {
117118

118119
// Our app has a listener on 'dblclick' event in our 'scripts.js'
119120
// that hides the div and shows an input on double click
120-
cy.get('.action-div').dblclick().should('not.be.visible')
121+
cy.get('.action-div').dblclick()
122+
cy.get('.action-div').should('not.be.visible')
121123
cy.get('.action-input-hidden').should('be.visible')
122124
})
123125

@@ -126,7 +128,8 @@ context('Actions', () => {
126128

127129
// Our app has a listener on 'contextmenu' event in our 'scripts.js'
128130
// that hides the div and shows an input on right click
129-
cy.get('.rightclick-action-div').rightclick().should('not.be.visible')
131+
cy.get('.rightclick-action-div').rightclick()
132+
cy.get('.rightclick-action-div').should('not.be.visible')
130133
cy.get('.rightclick-action-input-hidden').should('be.visible')
131134
})
132135

@@ -135,26 +138,26 @@ context('Actions', () => {
135138

136139
// By default, .check() will check all
137140
// matching checkbox or radio elements in succession, one after another
138-
cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]')
139-
.check().should('be.checked')
141+
cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]').check()
142+
cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]').should('be.checked')
140143

141-
cy.get('.action-radios [type="radio"]').not('[disabled]')
142-
.check().should('be.checked')
144+
cy.get('.action-radios [type="radio"]').not('[disabled]').check()
145+
cy.get('.action-radios [type="radio"]').not('[disabled]').should('be.checked')
143146

144147
// .check() accepts a value argument
145-
cy.get('.action-radios [type="radio"]')
146-
.check('radio1').should('be.checked')
148+
cy.get('.action-radios [type="radio"]').check('radio1')
149+
cy.get('.action-radios [type="radio"]').should('be.checked')
147150

148151
// .check() accepts an array of values
149-
cy.get('.action-multiple-checkboxes [type="checkbox"]')
150-
.check(['checkbox1', 'checkbox2']).should('be.checked')
152+
cy.get('.action-multiple-checkboxes [type="checkbox"]').check(['checkbox1', 'checkbox2'])
153+
cy.get('.action-multiple-checkboxes [type="checkbox"]').should('be.checked')
151154

152155
// Ignore error checking prior to checking
153-
cy.get('.action-checkboxes [disabled]')
154-
.check({ force: true }).should('be.checked')
156+
cy.get('.action-checkboxes [disabled]').check({ force: true })
157+
cy.get('.action-checkboxes [disabled]').should('be.checked')
155158

156-
cy.get('.action-radios [type="radio"]')
157-
.check('radio3', { force: true }).should('be.checked')
159+
cy.get('.action-radios [type="radio"]').check('radio3', { force: true })
160+
cy.get('.action-radios [type="radio"]').should('be.checked')
158161
})
159162

160163
it('.uncheck() - uncheck a checkbox element', () => {
@@ -164,21 +167,32 @@ context('Actions', () => {
164167
// checkbox elements in succession, one after another
165168
cy.get('.action-check [type="checkbox"]')
166169
.not('[disabled]')
167-
.uncheck().should('not.be.checked')
170+
.uncheck()
171+
cy.get('.action-check [type="checkbox"]')
172+
.not('[disabled]')
173+
.should('not.be.checked')
168174

169175
// .uncheck() accepts a value argument
170176
cy.get('.action-check [type="checkbox"]')
171177
.check('checkbox1')
172-
.uncheck('checkbox1').should('not.be.checked')
178+
cy.get('.action-check [type="checkbox"]')
179+
.uncheck('checkbox1')
180+
cy.get('.action-check [type="checkbox"][value="checkbox1"]')
181+
.should('not.be.checked')
173182

174183
// .uncheck() accepts an array of values
175184
cy.get('.action-check [type="checkbox"]')
176185
.check(['checkbox1', 'checkbox3'])
177-
.uncheck(['checkbox1', 'checkbox3']).should('not.be.checked')
186+
cy.get('.action-check [type="checkbox"]')
187+
.uncheck(['checkbox1', 'checkbox3'])
188+
cy.get('.action-check [type="checkbox"][value="checkbox1"]')
189+
.should('not.be.checked')
190+
cy.get('.action-check [type="checkbox"][value="checkbox3"]')
191+
.should('not.be.checked')
178192

179193
// Ignore error checking prior to unchecking
180-
cy.get('.action-check [disabled]')
181-
.uncheck({ force: true }).should('not.be.checked')
194+
cy.get('.action-check [disabled]').uncheck({ force: true })
195+
cy.get('.action-check [disabled]').should('not.be.checked')
182196
})
183197

184198
it('.select() - select an option in a <select> element', () => {
@@ -196,17 +210,20 @@ context('Actions', () => {
196210

197211
cy.get('.action-select-multiple')
198212
.select(['apples', 'oranges', 'bananas'])
213+
cy.get('.action-select-multiple')
199214
// when getting multiple values, invoke "val" method first
200215
.invoke('val')
201216
.should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
202217

203218
// Select option(s) with matching value
204219
cy.get('.action-select').select('fr-bananas')
220+
cy.get('.action-select')
205221
// can attach an assertion right away to the element
206222
.should('have.value', 'fr-bananas')
207223

208224
cy.get('.action-select-multiple')
209225
.select(['fr-apples', 'fr-oranges', 'fr-bananas'])
226+
cy.get('.action-select-multiple')
210227
.invoke('val')
211228
.should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
212229

@@ -227,20 +244,23 @@ context('Actions', () => {
227244

228245
// scroll the button into view, as if the user had scrolled
229246
cy.get('#scroll-horizontal button').scrollIntoView()
247+
cy.get('#scroll-horizontal button')
230248
.should('be.visible')
231249

232250
cy.get('#scroll-vertical button')
233251
.should('not.be.visible')
234252

235253
// Cypress handles the scroll direction needed
236254
cy.get('#scroll-vertical button').scrollIntoView()
255+
cy.get('#scroll-vertical button')
237256
.should('be.visible')
238257

239258
cy.get('#scroll-both button')
240259
.should('not.be.visible')
241260

242261
// Cypress knows to scroll to the right and down
243262
cy.get('#scroll-both button').scrollIntoView()
263+
cy.get('#scroll-both button')
244264
.should('be.visible')
245265
})
246266

@@ -255,7 +275,9 @@ context('Actions', () => {
255275
// the value and trigger the 'change' event
256276
cy.get('.trigger-input-range')
257277
.invoke('val', 25)
278+
cy.get('.trigger-input-range')
258279
.trigger('change')
280+
cy.get('.trigger-input-range')
259281
.get('input[type=range]').siblings('p')
260282
.should('have.text', '25')
261283
})

cypress/e2e/2-advanced-examples/cookies.cy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ context('Cookies', () => {
8282
cy.getCookie('token').should('have.property', 'value', '123ABC')
8383

8484
// cy.clearCookies() yields null
85-
cy.clearCookie('token').should('be.null')
85+
cy.clearCookie('token')
86+
cy.getCookie('token').should('be.null')
8687

8788
cy.getCookie('token').should('be.null')
8889
})

cypress/e2e/2-advanced-examples/misc.cy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ context('Misc', () => {
1212
// and force Cypress to re-query from the root element
1313
cy.get('.misc-table').within(() => {
1414
// ends the current chain and yields null
15-
cy.contains('Cheryl').click().end()
15+
cy.contains('Cheryl').click()
16+
//.end()
1617

1718
// queries the entire table again
1819
cy.contains('Charles').click()

cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ context('Spies, Stubs, and Clock', () => {
7676
cy.clock(now)
7777
cy.visit('http://localhost:8080/commands/spies-stubs-clocks')
7878
cy.get('#clock-div').click()
79+
cy.get('#clock-div')
7980
.should('have.text', '1489449600')
8081
})
8182

@@ -89,10 +90,12 @@ context('Spies, Stubs, and Clock', () => {
8990
cy.clock(now)
9091
cy.visit('http://localhost:8080/commands/spies-stubs-clocks')
9192
cy.get('#tick-div').click()
93+
cy.get('#tick-div')
9294
.should('have.text', '1489449600')
9395

9496
cy.tick(10000) // 10 seconds passed
9597
cy.get('#tick-div').click()
98+
cy.get('#tick-div')
9699
.should('have.text', '1489449610')
97100
})
98101

cypress/e2e/2-advanced-examples/storage.cy.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,48 @@ context('Local Storage / Session Storage', () => {
1010

1111
it('cy.clearLocalStorage() - clear all data in localStorage for the current origin', () => {
1212
// https://on.cypress.io/clearlocalstorage
13-
cy.get('.ls-btn').click().should(() => {
13+
cy.get('.ls-btn').click()
14+
cy.get('.ls-btn').should(() => {
1415
expect(localStorage.getItem('prop1')).to.eq('red')
1516
expect(localStorage.getItem('prop2')).to.eq('blue')
1617
expect(localStorage.getItem('prop3')).to.eq('magenta')
1718
})
1819

19-
// clearLocalStorage() yields the localStorage object
20-
cy.clearLocalStorage().should((ls) => {
21-
expect(ls.getItem('prop1')).to.be.null
22-
expect(ls.getItem('prop2')).to.be.null
23-
expect(ls.getItem('prop3')).to.be.null
20+
cy.clearLocalStorage()
21+
cy.getAllLocalStorage().should(() => {
22+
expect(localStorage.getItem('prop1')).to.be.null
23+
expect(localStorage.getItem('prop2')).to.be.null
24+
expect(localStorage.getItem('prop3')).to.be.null
2425
})
2526

26-
cy.get('.ls-btn').click().should(() => {
27+
cy.get('.ls-btn').click()
28+
cy.get('.ls-btn').should(() => {
2729
expect(localStorage.getItem('prop1')).to.eq('red')
2830
expect(localStorage.getItem('prop2')).to.eq('blue')
2931
expect(localStorage.getItem('prop3')).to.eq('magenta')
3032
})
3133

3234
// Clear key matching string in localStorage
33-
cy.clearLocalStorage('prop1').should((ls) => {
34-
expect(ls.getItem('prop1')).to.be.null
35-
expect(ls.getItem('prop2')).to.eq('blue')
36-
expect(ls.getItem('prop3')).to.eq('magenta')
35+
cy.clearLocalStorage('prop1')
36+
cy.getAllLocalStorage().should(() => {
37+
expect(localStorage.getItem('prop1')).to.be.null
38+
expect(localStorage.getItem('prop2')).to.eq('blue')
39+
expect(localStorage.getItem('prop3')).to.eq('magenta')
3740
})
3841

39-
cy.get('.ls-btn').click().should(() => {
42+
cy.get('.ls-btn').click()
43+
cy.get('.ls-btn').should(() => {
4044
expect(localStorage.getItem('prop1')).to.eq('red')
4145
expect(localStorage.getItem('prop2')).to.eq('blue')
4246
expect(localStorage.getItem('prop3')).to.eq('magenta')
4347
})
4448

4549
// Clear keys matching regex in localStorage
46-
cy.clearLocalStorage(/prop1|2/).should((ls) => {
47-
expect(ls.getItem('prop1')).to.be.null
48-
expect(ls.getItem('prop2')).to.be.null
49-
expect(ls.getItem('prop3')).to.eq('magenta')
50+
cy.clearLocalStorage(/prop1|2/)
51+
cy.getAllLocalStorage().should(() => {
52+
expect(localStorage.getItem('prop1')).to.be.null
53+
expect(localStorage.getItem('prop2')).to.be.null
54+
expect(localStorage.getItem('prop3')).to.eq('magenta')
5055
})
5156
})
5257

@@ -72,10 +77,11 @@ context('Local Storage / Session Storage', () => {
7277
cy.get('.ls-btn').click()
7378

7479
// clearAllLocalStorage() yields null
75-
cy.clearAllLocalStorage().should(() => {
76-
expect(sessionStorage.getItem('prop1')).to.be.null
77-
expect(sessionStorage.getItem('prop2')).to.be.null
78-
expect(sessionStorage.getItem('prop3')).to.be.null
80+
cy.clearAllLocalStorage()
81+
cy.getAllLocalStorage().should(() => {
82+
expect(localStorage.getItem('prop1')).to.be.null
83+
expect(localStorage.getItem('prop2')).to.be.null
84+
expect(localStorage.getItem('prop3')).to.be.null
7985
})
8086
})
8187

@@ -101,7 +107,8 @@ context('Local Storage / Session Storage', () => {
101107
cy.get('.ls-btn').click()
102108

103109
// clearAllSessionStorage() yields null
104-
cy.clearAllSessionStorage().should(() => {
110+
cy.clearAllSessionStorage()
111+
cy.getAllSessionStorage().should(() => {
105112
expect(sessionStorage.getItem('prop4')).to.be.null
106113
expect(sessionStorage.getItem('prop5')).to.be.null
107114
expect(sessionStorage.getItem('prop6')).to.be.null

0 commit comments

Comments
 (0)