-
Notifications
You must be signed in to change notification settings - Fork 35
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
initial playwright setup and test #1039
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
0edc612
to
9efd6f0
Compare
3a04774
to
196e6d9
Compare
c341ed8 failed for reasons unrelated to playwright. |
Looks very nice! Saw this PR on Twitter and wanted to give some feedback: I saw that there are a bunch of awaits missing in Also instead of doing I saw you are doing nit: Its also possible to run an individual test by line number, e.g. All these are minor issues, looks great! |
…ests (#1114) * Ensure that Vite is serving before tests run * Don't break secrets if developer has extra blank line in env file
Awesome @mxschmitt! Heaps of good tips there thank you! I'll get cracking on those and no I hadn't tried UI mode. I'll give that a go. |
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.
Thanks again @mxschmitt, and of course thanks for your work on such a great tool!
I integrated all of your suggestions in 5f4cec1 with the exception of fixtures, I want to think about that a little more but created #1116.
I also have one remaining waitForFunction
as noted below.
Also, UI mode is great, one minor inconvenience is the video only shows up in the timeline, but only minor.
But one great thing about UI mode is that it works with Google Chrome
, as the "record new" and "record at cursor" extension features seemed to only launch with chromium, and we have a video encoding compat issue with that, so being able to use locator feature in UI-mode is great.
await page.waitForFunction( | ||
() => | ||
document.querySelectorAll('[data-receive-command-type="object_visible"]') | ||
.length >= 3 | ||
) |
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 couldn't figure out how to make a locator that waited for three of the same selector to appear, so kept this for the time being.
I'm going to merge this, even though the playwright CI is failing, it's because our dev engine has an issue right now. CI was passing before and the tests work locally. |
Resolves to #1038
Because clicking around in our app will often only change pixel in the stream and not HTML, it kind of breaks how these e2e tests usually work. I've explained our workaround in a few places, but probably the best explanation because it also has a bit of a tutorial on how to get started writing a test for our app is here (15min watch)
Screen.Recording.2023-11-21.at.11.37.07.am.mp4
But the nuts and bolts of how we wait for changes from the engine is the react component in
src/components/EngineCommands.tsx
, but some changes tosrc/lang/std/engineConnection.ts
were needed to.Other random notes:
data-
attributes is a sanctioned way to add arbitrary attributes to HTML, and they give us something easy to query for in the command log/debug panel. Note thatdata-testid
is a common convention for testing frameworks, having said that if you had the element<button data-testid="my-el">My Button</button>
the following querypage.getByRole('button', { name: 'My Button' })
is better thanawait page.getByTestId('my-el')
because the former more closely represents how the user identities and interacts with the button. If the text within the button changed a lot because it uses a variable then using the testid might be warranted.