-
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: handle async before:spec event handler #26055
Conversation
30 flaky tests on run #44687 ↗︎
Details:
create-from-component.cy.ts • 1 flaky test • app-e2e
specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e
cypress-origin-communicator.cy.ts • 1 flaky test • app-e2e
global-mode.cy.ts • 1 flaky test • launchpad-e2e
commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-chrome
The first 5 flaky specs are shown, see all 17 specs in Cypress Cloud. This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
project: 'plugin-after-spec-deletes-video', | ||
spec: '*', | ||
project: 'plugin-run-events', | ||
// project: 'plugin-after-spec-deletes-video', |
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 remove comment
onMounted(() => { | ||
// watch active spec, and re-run if it changes! | ||
startSpecWatcher() |
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 wonder why we needed to wait until the element was rendered to call this?
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.
this is left over from attempts in trying to correct this behavior in open mode. changing back for now. but my original thought was there wasn't any. need to watch if a spec was changes from a user in the app if the content wasn't mounted & rendered yet.
@@ -361,19 +360,31 @@ export class EventManager { | |||
} | |||
|
|||
setup (config) { | |||
Cypress = this.Cypress = this.$CypressDriver.create(config) | |||
this.ws.emit('watch:test:file', config.spec) |
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.
Do we want to watch the test file during run mode? This sounds like an open mode specific thing.
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.
Eg should this be under the check on line 365-368?
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.
It likely should but that is outside of the scope of this change and would require additionally testing. Going to leave as it for the PR.
this.ws.emit('watch:test:file', config.spec) | ||
resolve(null) | ||
}) | ||
}).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.
You can (probably) just use async/await
here (if you want, that is - I don't think this part is impacted by the whole "async doesn't work properly" since this is outside of the driver, but either way is fine by me.
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.
The async won't work properly
concept is tied to writing Cypress tests, not the code so await should work fine.
I will assign @cypress-io/component-testing, since we are working in this area the most nowdays. |
…s-io/cypress into emily/before-spec-promise
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.
Great, looks good to me.
Correctly await async
before:spec
event handlers per the documentation specifications.PR Tasks
cypress-documentation
?type definitions
?