Skip to content

Commit 6a1879b

Browse files
authored
test: fix flake in readFile retries to read when ENOENT (#33510)
1 parent a6f2df6 commit 6a1879b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

packages/driver/cypress/e2e/commands/files.cy.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,19 @@ describe('src/cy/commands/files', () => {
9292

9393
err.code = 'ENOENT'
9494

95-
let retries = 0
96-
97-
cy.on('command:retry', () => {
98-
retries += 1
99-
})
100-
10195
Cypress.backend.withArgs('run:privileged')
10296
.onFirstCall()
10397
.rejects(err)
10498
.onSecondCall()
10599
.resolves(okResponse)
106100

107101
cy.readFile('foo.json').then(() => {
108-
expect(retries).to.eq(2)
102+
// Verify two calls were indeed made: the first one to fail, and the second one to succeed.
103+
const readFilePrivilegedCalls = Cypress.backend.getCalls().filter(
104+
(c) => c.args[0] === 'run:privileged' && c.args[1]?.commandName === 'readFile',
105+
)
106+
107+
expect(readFilePrivilegedCalls.length).to.eq(2)
109108
})
110109
})
111110

0 commit comments

Comments
 (0)