Open samtsai opened 2 years ago
Owner of cypress-terminal-report shared this: Unfortunately this plugin cannot do much to prevent this. We already have tests supporting dynamic skipping and they are all passing ok.
The issue is with @cypress/skip-test, as they are violating the queue nature of cypress. The following change in that plugin could fix your issue. Open an issue on that project or use patch-package
.
diff --git a/node_modules/@cypress/skip-test/index.js b/node_modules/@cypress/skip-test/index.js
index 03bf1c6..359f21d 100644
--- a/node_modules/@cypress/skip-test/index.js
+++ b/node_modules/@cypress/skip-test/index.js
@@ -71,8 +71,10 @@ const isOn = (name) => {
// @ts-ignore "cy.state" is not in the "cy" type
const getMochaContext = () => cy.state('runnable').ctx
const skip = () => {
- const ctx = getMochaContext()
- return ctx.skip()
+ cy.wrap({}).then(() => {
+ const ctx = getMochaContext()
+ return ctx.skip()
+ });
}
const isPlatform = (name) => ['win32', 'darwin', 'linux'].includes(name)
Originally posted by @archfz in https://github.com/archfz/cypress-terminal-report/issues/162#issuecomment-1213427121
Description
When using
cypress-terminal-report
withenableExtendedCollector
enabled and@cypress/skip-test
, the test will fail with a CypressError if the skip check is done in abefore
hook.The error below is triggered by: https://github.com/archfz/cypress-terminal-report/blob/a785736b6c1c2ebe56763ea332886dfef12b51a1/src/collector/LogCollectExtendedControl.js#L76
Reproducible Example
Run the spec test until you hit the error (sometimes it runs without an error).
https://github.com/samtsai/terminal-report-and-skip-tests-bug
Hits this CypressError: