Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/driver/cypress/e2e/commands/navigation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,13 @@ describe('src/cy/commands/navigation', () => {
})

describe('when origins don\'t match', () => {
let mockGetTestsState

beforeEach(() => {
Cypress.emit('test:before:run', { id: 'r2' })

cy.stub(Cypress.runner, 'getEmissions').returns([])
cy.stub(Cypress.runner, 'getTestsState').returns([])
mockGetTestsState = cy.stub(Cypress.runner, 'getTestsState').returns([])
cy.stub(Cypress.runner, 'getStartTime').returns('12345')
cy.stub(Cypress.Log, 'countLogsByTests').withArgs([]).returns(1)
cy.stub(Cypress.runner, 'countByTestState')
Expand Down Expand Up @@ -993,7 +995,9 @@ describe('src/cy/commands/navigation', () => {
.withArgs('preserve:run:state')
.callsFake(fn)

cy.visit('http://localhost:4200')
cy.visit('http://localhost:4200').then(() => {
expect(mockGetTestsState).to.be.calledWith('r2')
})
})

it('replaces window.location when origins don\'t match', (done) => {
Expand Down Expand Up @@ -1024,7 +1028,9 @@ describe('src/cy/commands/navigation', () => {
.withArgs('preserve:run:state')
.resolves()

cy.visit('http://localhost:4200')
cy.visit('http://localhost:4200').then(() => {
expect(mockGetTestsState).to.be.calledWith('r2')
})
})
})

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ export default (Commands, Cypress, cy, state, config) => {
// state for like scrollTop
let runState: RunState = {
currentId: id,
tests: Cypress.runner.getTestsState(),
tests: Cypress.runner.getTestsState(id),
startTime: Cypress.runner.getStartTime(),
emissions: Cypress.runner.getEmissions(),
}
Expand Down
3 changes: 1 addition & 2 deletions packages/driver/src/cypress/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,8 +1901,7 @@ export default {
return _emissions
},

getTestsState () {
const id = _test != null ? _test.id : undefined
getTestsState (id: string) {
const tests = {}

// bail if we dont have a current test
Expand Down