-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Recovered Error Handling and Session Recovered Errors #24511
Changes from 55 commits
bd0a0ee
159e4ad
fa44f35
d6dde1c
1d3584d
4dc9e6b
0dfbb99
b10cdc4
c2a1b5c
342f701
fea09e9
c868386
e25419b
f09ba08
85a2b07
2b593de
db28fd1
bfa869f
9e7a463
fdda301
56f4c2a
2cd8cae
0ab8846
d51cc95
cdafd9f
27ce5e4
338d3b8
b904344
2446db9
7d4e8e7
18761c9
4902429
898cab6
8d36df5
5cf2ad7
c41e537
44727c4
87ffa23
125df05
c602c34
200b7f7
e17ee7d
7a490ba
3719c91
3789d5d
0cdadc8
7a3ece9
5b137ec
f34fac4
d6a6f90
c515ae0
28f6add
443e311
ff8deb5
4fe9cf0
8952a2b
2921590
3f2e50d
1f87967
e113104
d1eee3a
2a7bb06
b8e919f
1d52b05
8584bda
919dd4a
9172359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,16 +48,16 @@ describe('src/cy/commands/assertions', () => { | |
this.logs = [] | ||
|
||
cy.on('log:added', (attrs, log) => { | ||
this.logs.push(log) | ||
this.logs?.push(log) | ||
this.lastLog = log | ||
}) | ||
|
||
return null | ||
}) | ||
|
||
it('returns the subject for chainability', () => { | ||
cy | ||
.noop({ foo: 'bar' }).should('deep.eq', { foo: 'bar' }) | ||
cy.noop({ foo: 'bar' }) | ||
.should('deep.eq', { foo: 'bar' }) | ||
.then((obj) => { | ||
expect(testCommands()).to.eql([ | ||
{ name: 'visit', snapshots: 1, retries: 0 }, | ||
|
@@ -368,7 +368,7 @@ describe('src/cy/commands/assertions', () => { | |
|
||
cy.on('log:added', (attrs, log) => { | ||
if (log.get('name') === 'assert') { | ||
logs.push(log) | ||
logs?.push(log) | ||
|
||
if (logs.length === 3) { | ||
done() | ||
|
@@ -416,34 +416,40 @@ describe('src/cy/commands/assertions', () => { | |
it('does not log extra commands on fail and properly fails command + assertions', function (done) { | ||
cy.on('fail', (err) => { | ||
assertLogLength(this.logs, 6) | ||
expect(err.message).to.eq('You must provide a valid number to a `length` assertion. You passed: `asdf`') | ||
|
||
expect(this.logs[3].get('name')).to.eq('get') | ||
expect(this.logs[3].get('state')).to.eq('failed') | ||
expect(this.logs[3].get('error')).to.eq(err) | ||
expect(this.logs[3].get('state')).to.eq('passed') | ||
expect(this.logs[3].get('error')).to.be.undefined | ||
|
||
expect(this.logs[4].get('name')).to.eq('assert') | ||
expect(this.logs[4].get('state')).to.eq('failed') | ||
expect(this.logs[4].get('error').name).to.eq('AssertionError') | ||
expect(this.logs[4].get('error').name).to.eq('CypressError') | ||
expect(this.logs[4].get('error')).to.eq(err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the assertion fails, I would expect an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that at first too, but this is one of our own errors: |
||
|
||
done() | ||
}) | ||
|
||
cy | ||
.root().should('exist').and('contain', 'foo') | ||
.get('button').should('have.length', 'asdf') | ||
.root() | ||
.should('exist') | ||
.and('contain', 'foo') | ||
.get('button') | ||
.should('have.length', 'asdf') | ||
}) | ||
|
||
it('finishes failed assertions and does not log extra commands when cy.contains fails', function (done) { | ||
cy.on('fail', (err) => { | ||
assertLogLength(this.logs, 2) | ||
|
||
expect(this.logs[0].get('name')).to.eq('contains') | ||
expect(this.logs[0].get('state')).to.eq('failed') | ||
expect(this.logs[0].get('error')).to.eq(err) | ||
expect(this.logs[0].get('state')).to.eq('passed') | ||
expect(this.logs[0].get('error')).to.be.undefined | ||
|
||
expect(this.logs[1].get('name')).to.eq('assert') | ||
expect(this.logs[1].get('state')).to.eq('failed') | ||
expect(this.logs[1].get('error').name).to.eq('AssertionError') | ||
expect(this.logs[1].get('error').name).to.eq('CypressError') | ||
expect(this.logs[1].get('error')).to.eq(err) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
done() | ||
}) | ||
|
@@ -731,7 +737,7 @@ describe('src/cy/commands/assertions', () => { | |
}) | ||
|
||
it('does not additionally log when .should is the current command', function (done) { | ||
cy.on('fail', (err) => { | ||
cy.once('fail', (err) => { | ||
const { lastLog } = this | ||
|
||
assertLogLength(this.logs, 1) | ||
|
@@ -822,7 +828,7 @@ describe('src/cy/commands/assertions', () => { | |
this.logs = [] | ||
|
||
cy.on('log:added', (attrs, log) => { | ||
this.logs.push(log) | ||
this.logs?.push(log) | ||
|
||
if (attrs.name === 'assert') { | ||
this.lastLog = log | ||
|
@@ -1023,7 +1029,7 @@ describe('src/cy/commands/assertions', () => { | |
expected: false, | ||
actual: true, | ||
Message: 'expected true to be false', | ||
Error: log.get('error').stack, | ||
Error: log.get('error').message, | ||
}) | ||
|
||
done() | ||
|
@@ -1179,7 +1185,7 @@ describe('src/cy/commands/assertions', () => { | |
this.logs = [] | ||
|
||
cy.on('log:added', (attrs, log) => { | ||
this.logs.push(log) | ||
this.logs?.push(log) | ||
}) | ||
|
||
return null | ||
|
@@ -1621,7 +1627,7 @@ describe('src/cy/commands/assertions', () => { | |
} | ||
|
||
cy.on('log:added', (attrs, log) => { | ||
this.logs.push(log) | ||
this.logs?.push(log) | ||
}) | ||
|
||
return null | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was seeing a ton of errors for cannot pushed to defined throughout our tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious. How is
this.logs
undefined when it's defined above?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seemed to happen it was when I'd change a file or the spec file and Cypress would start to rerun the spec. 🤷🏻♀️Maybe the previous cy.on listener is still attached when the page is loading?? Seems a bit odd to me, but was tired of getting
uncaught exception
logs when debugging 😬There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we drop a comment there to explain this behavior incase someone runs into it again and thinks the optional chainer isn't necessary?