Skip to content

Commit 8e4ebef

Browse files
author
Blue F
authored
fix: Aliases properly retry commands from inside custom commands (#23663)
1 parent a6067a7 commit 8e4ebef

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ describe('src/cy/commands/aliasing', () => {
101101
expect(this.input).to.eq(obj)
102102
})
103103
})
104+
105+
it('retries previous commands invoked inside custom commands', () => {
106+
Cypress.Commands.add('get2', (selector) => cy.get(selector))
107+
108+
cy.get2('body').children('div').as('divs')
109+
cy.visit('/fixtures/dom.html')
110+
111+
cy.get('@divs')
112+
})
104113
})
105114

106115
context('#assign', () => {

packages/driver/src/cypress/cy.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1230,11 +1230,13 @@ export class $Cy extends EventEmitter2 implements ITimeouts, IStability, IAssert
12301230
}
12311231

12321232
// A workaround to ensure that when looking back, aliases don't extend beyond the current
1233-
// chainer. This whole area (`replayCommandsFrom` for aliases) will be replaced with subject chains as
1234-
// part of the detached DOM work.
1233+
// chainer and commands invoked inside of it. This whole area (`replayCommandsFrom` for aliases)
1234+
// will be replaced with subject chains as part of the detached DOM work.
1235+
const chainerId = command.get('chainerId')
12351236
const prev = command.get('prev')
1237+
const prevChainer = prev.get('chainerId')
12361238

1237-
if (prev.get('chainerId') !== command.get('chainerId')) {
1239+
if (prevChainer !== chainerId && cy.state('subjectLinks')[prevChainer] !== chainerId) {
12381240
return memo
12391241
}
12401242

0 commit comments

Comments
 (0)