-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/auto waiting #5
Conversation
249da27
to
30fb5b2
Compare
This looks fine to me at the first glance. Have to still pull the code and try it locally. Can you please add some notes around
|
I'm not 100% sure were you'd like those notes, but to begin with I can answer the questions here: If the old assertions will continue to work as it is. The old assertions will assert the same things as before, but when an expectation is not met, they will keep checking until they succeed or time out, at which point they will raise the same assertion errors as before. Since this change only adds an extra opportunity for an assertion to succeed I don't believe it will cause existing specs to fail. That is as long as the spec does not anticipate an assertion error, which would be bad practice (unless for testing the assertion itself). In regards to failing specs, failures will take a bit longer, because they will need to time out before they fail. I see, you have introduced a config object and how that will be passed from the user-land. It will be passed as part of the PluginConfig when setting up the browser test plugin, e.g.:
The above will make the assertions wait for up-to 1 second before failiing. The config object is the same as for Are are exposing the playwright I expose it as a part of the test context, so that the end-user can easily get hold of playwright's I am however a bit worried that "expect" is too generic a property name to have added directly to the test context. I'd understand if you prefer it to have it nested, f.i. under |
Btw.: I will go ahead with implementing the remaining assertions |
Hello! Yeah, sorry for not being clear. I meant adding notes in the PR description or comment.
Yeah, we already have |
350138b
to
c35b519
Compare
No problem. I would however prefer if it could be destructured directly to As I see it we should pick one of the following solutions: Namespace expect under test('assert page title', async ({ browser, pw: { expect } }) => {
...
await expect(page.locator('a')).toBeVisible()
}) Pros:
Cons:
Use test('assert page title', async ({ browser, pwExpect } }) => {
...
await pwExpect(page.locator('a')).toBeVisible()
}) Pros:
Cons:
Use test('assert page title', async ({ browser, pwExpect: expect } }) => {
...
await expect(page.locator('a')).toBeVisible()
}) Pros:
Cons:
After having given all the solutions some thought - while writing this comment - I'm still leaning towards name spacing. I feel that the benefit of being able to write more idiomatic playwright code outweighs the negatives. |
@thetutlage So instead of reimplementing all specs using playwright's The advantages are:
The disadvantage is: Those functions are however completely self-contained and could easily be pulled into Could you take a look at src/decorators/assertions.ts and let me know what you think about this approach? |
Is it something inherent with Playwright that their expectations do not throw error and instead mark the test as failed internally? |
If you ask on the options for 3 API's. I will go with the 3rd one. I think its the balanced in many ways.
|
You can see what it does here: Basically they grab the message from the error/assertion object, then append some timeout info to that message and return an object in their own internal format.
Fine with me π |
101ca34
to
b1142df
Compare
I believe this PR is ready for review now. I've reduced the scope of the PR so that it only implements auto-retry (with optional plugin settings). From a user perspective the changes are:
To implement auto-retry I've lifted some utilities out of playwright and placed them under a new If we want to customize the time-out per test or per assertion, that is something we will need to add later. For now I think this will be enough to greatly improve the DX when using Let me know what you think.. |
b1142df
to
9ec8aea
Compare
Hey @jeppester! ππ» Amazing work β thank you for all the effort! I just had a quick question about the changes: whatβs the reason for adding the Apache 2 license and the NOTICE.md file? |
UPDATE |
30030ea
to
4a1b779
Compare
I think, I will have no issues with attribution at all. So you can decide either we want to keep the retry logic you have implemented or copy over the playwright files. Its upto you :) |
@jeppester Seems like tests and the lint workflow are failing. Can you please look into it? |
And ensure that all specs test their failure states
4a1b779
to
29be725
Compare
The downside is that my implementation is obviously not as battle tested as playwright's and is therefore more likely to contain bugs/oversights. But if you're happy with my implementation, let's keep that.
Sure. I was running all the tests through |
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.
Can we please have some tests that uses the pollIntervals
, or maybe tests for the retry
helper will be even better.
Otherwise the PR looks great. Thanks for taking out time π
I'll see what I can do π
No problem. I'm just trying to make adonis look as good as possible now that I've convinced my team to try it out π |
ad80a59
to
ce5c996
Compare
@thetutlage I added tests for |
ce5c996
to
fcba262
Compare
@jeppester Can you please check why the tests are failing? They are failing just on Windows in CI |
Apparently setTimeout is less precise on windows (or just on that specific machine, or due to load), so the allowed deviation is too small. I'll make it 25 or maybe 50 instead of 5, so that the current failure is far within the limit. |
To make tests pass consistently on Windows
@thetutlage I updated the spec to allow more deviation. I also improved the coverage and fixed a problem where the timeout was not correctly added to the error message. Please retry the specs. |
Thanks @jeppester . Let's get it out in a couple of days |
Should I update the documentation on japa.dev? |
@jeppester Yeah, it will be nice if you can open a PR for docs too |
π Linked issue
#1
β Type of change
π Description
Implements waiting behaviour for the assertions added to the playwright page.
Resolves #1.
Let me know if this approach seems good to you, so that I can confidently implement the remaining assertions and update the documentation.
π Checklist