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
Don't use expect within Promises (#5466) #5473
Conversation
28da0f6
to
2a17630
Compare
@mathiasbynens, in regards of the Travis and AppVeyor failure for navitation.spec.js shouldn't |
test/navigation.spec.js
Outdated
let error = null; | ||
await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e); | ||
if (CHROME) | ||
expect(error.message).toContain('net::ERR_CERT_AUTHORITY_INVALID'); | ||
else | ||
expect(error.message).toContain('SSL_ERROR_UNKNOWN'); | ||
expect(requests.length).toBe(3); | ||
for (const request of requests) | ||
expect(request).toBeTruthy(); |
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.
@mathiasbynens this change actually caused tests to fail for Chrome:
https://travis-ci.com/github/puppeteer/puppeteer/jobs/293846770#L543
Any suggestion what has to be done to get this fixed? Maybe waiting until the length is 3?
Hey @whimboo I'm afraid we've got some conflicts now we've done some updates to the test runner (we now use Mocha rather than a custom one). Would you be up for rebasing and landing this work? I'm happy to work with you to figure out that navigation.spec.js test if it's still causing issues after a rebase. |
Hey @jackfranklin. Sorry for not replying earlier but I missed the Github notification. I will have a look in updating this PR (in case the changes are still needed). Maybe I will have something later today. |
@whimboo no probs! Ping me if I can help :) |
2a17630
to
b814774
Compare
I hope the recently pushed changes will work. I'm currently not able to test locally because of the following failure message:
And there is not such a |
@whimboo can you run |
Oh |
b814774
to
3a2509c
Compare
3a2509c
to
c6c1435
Compare
@jackfranklin the problem with the navigation test failure still exists: |
I assume this is a bug in the test and that we should not expect
|
0e917d5
to
13b0545
Compare
@jackfranklin if those checks are fine, all the tests passing now. |
const requests = []; | ||
page.on('request', (request) => requests.push('request')); | ||
page.on('requestfinished', (request) => requests.push('requestfinished')); | ||
page.on('requestfailed', (request) => requests.push('requestfailed')); |
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.
@whimboo to check my understanding; do you think this test used to pass because we've never get a requestfinished
event and therefore that expectation would never run?
@mathiasbynens do you have any thoughts on if we should be getting the requestfinished
event? I think it makes sense that we don't, given that this test checks that requests fail and therefore I wouldn't expect the requestfinished
event necessarily. I think this was a mistake in the test that made it in and happened to not cause any issues.
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.
Yes, exactly. I think we either get requestfinished
or requestfailed
. But agreed that this is something @mathiasbynens should reply on.
@jackfranklin also I assume half of the changes for this PR are super-seeded by your PR #5859? |
No problem at all. Are the changes to the navigation tests ok, or would they have to be updated similar to your dialog changes? |
@whimboo apologies, this slipped off my radar. I just tried to rebase on GitHub but I've made a mistake and now the tests are failing. If you could tidy up the failing test on your fork and push then this will be good to merge. Thanks! |
test/dialog.spec.js
Outdated
@@ -54,6 +57,9 @@ describe('Page.Events.Dialog', function () { | |||
expect(dialog.message()).toBe('question?'); | |||
|
|||
expect(result).toBe('answer!'); | |||
expect(type).toBe('prompt'); | |||
expect(defaultValue).toBe('yes.'); | |||
expect(message).toBe('question?'); |
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.
@jackfranklin do we still need those changes or are all of these obsolete now? Also what about the other test above. I assume it needs a similar call to sinon.stub().callsFake()
?
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 just pushed an update with that. So let me know if that is fine with you.
7b196cf
to
000b3b8
Compare
If a call to expect fails within a Promise it will not be resolved, and causing the test to crash. The patch aligns the code similar to what is used by all the other tests.
000b3b8
to
e0857d7
Compare
Tests are failing because of |
@whimboo thanks! Sorry again for the back and forth on this one. |
This PR will partly fix issue #5466.
If a call to expect fails within a Promise it will not
be resolved, and causing the test to crash.
The patch aligns the code similar to what is used by all
the other tests.