-
Notifications
You must be signed in to change notification settings - Fork 4.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 e2e test failure screenshots not capturing at the right time #28449
Conversation
Size Change: 0 B Total Size: 1.46 MB ℹ️ View Unchanged
|
Somehow when using
I've narrowed it down to this following call: await createNewPost({
postType: "wp_template",
title: templateName
}); Specifically the I have no idea why it's broken, and I don't have time to investigate it further now, might come back to it later. |
cedeac5
to
d070533
Compare
Found the root cause why it was breaking and fixed it.
The above error shown in the
I know very little about the template API so I don't know whether it's expected or not. Either way, it's already happening in trunk just that it didn't throw any error before. In trunk, we're using the default test runner To mimic the same behavior in |
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 tested locally by adding expect( 1 ).toBe( 2 )
in a test, and the artifacts folder had the correct screenshot 👍 🚢
It also made me realise I should delete the artifacts folder now and then 😮
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.
Any ideas why the changes to the package lock file are so big?
Nice one. It needs some documentation in the @wordpress/scripts
package to let people know that a new feature was added and where can expect to see failure screenshots on their disk.
@@ -9,6 +9,7 @@ const path = require( 'path' ); | |||
const { hasBabelConfig } = require( '../utils' ); | |||
|
|||
const jestE2EConfig = { | |||
testRunner: 'jest-circus/runner', |
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 update the test runner for unit tests as well for consistency?
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.
Worth a shot!
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.
Added in #31178
I think that's because the lock file in trunk was outdated. I believe it has been resolved recently though. A rebase would fix that.
It's not a new feature though, it was being added in #26664. This PR fixes a bug which caused it to not function correctly when there're async |
Good catch! |
It isn't a new feature in the Gutenberg repository. It's a new feature in the |
@draganescu Oops, this is not done yet, still have some notes left to do. I'll open another PR. |
Description
Continued from #26664. Fix the screenshots not being captured at the right time.
Specifically, if the tests have
afterEach
orafterAll
defined, the screenshots will be captured after these hooks are run. This PR usesjest-circus
as the test runner and extendsjest-environment-puppeteer
to run the capturing scripts in thetest_fn_failure
event.Not sure why the lock file has so many changes though.
How has this been tested?
Added some intentionally failing tests in https://github.com/WordPress/gutenberg/runs/2358561781 to demo the result. See the failing tests for the stored artifacts. The screenshots captured should correctly point to when it failed.
Types of changes
Bug fix
Checklist: