-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
[question] programatically mark a test to be skipped #704
Comments
Hey @onthespotqa, I've fixed this with v9.1.3. |
@badeball thanks. will install and let you know if there's an issue still |
@badeball so this works when i added the code inline, but not when its a package in a mono-repo. I've created a repo for reproducing the issue, that has a basic test that should be skipped. both the test suite and the yarn workspace package are on 9.1.3 and the latest cypress https://github.com/onthespotqa/cucumber-issue-repo |
So, it seems to work well when invoking
However, trying to save the context from
Why? I don't know, but I don't believe that it has got to do anything with the preprocessor. Saving contexts simply isn't documented and I expect all sorts of trouble to arise when you do it. Instead, I would do something like shown below. diff --git a/cucumber-tests/cypress/integration/common/quarantine.ts b/cucumber-tests/cypress/integration/common/quarantine.ts
index 0666895..2dfd74d 100644
--- a/cucumber-tests/cypress/integration/common/quarantine.ts
+++ b/cucumber-tests/cypress/integration/common/quarantine.ts
@@ -2,7 +2,7 @@ import {Given, Before} from "@badeball/cypress-cucumber-preprocessor"
import * as quarantine from 'cypress-quarantine';
Before(function () {
- quarantine.cucumberBefore();
+ quarantine.cucumberBefore(this);
})
Given(`A Step`, () =>{
diff --git a/cypress-quarantine/index.ts b/cypress-quarantine/index.ts
index 4207416..75e8968 100644
--- a/cypress-quarantine/index.ts
+++ b/cypress-quarantine/index.ts
@@ -1,38 +1,23 @@
let quarantineIsEnabled = true; // Toggle in order to stop or resume skipping tests in CI
let shouldSkip = false;
-var mochaContext;
-
// declare global {
// interface Window {
// testState: { gherkinDocument: IGherkinDocument; pickles: IPickle[]; pickle: IPickle; };
// }
// }
-beforeEach(function () {
- mochaContext = this;
-});
-
-export function mochaBeforeEach() {
- const quarantineManifest = Cypress.env('cypressQuarantine')
- if (quarantineIsEnabled) {
- const contextName = mochaContext.currentTest.parent.title;
- const testName = mochaContext.currentTest.title;
- skipTest(contextName, testName, quarantineManifest)
- }
-}
-
-export function cucumberBefore() {
+export function cucumberBefore(mochaContext) {
const quarantineManifest = Cypress.env('cypressQuarantine')
if (quarantineIsEnabled) {
const testState = window.testState;
const feature = testState.gherkinDocument.feature.name;
const scenario = testState.pickle.name;
- skipTest(feature, scenario, quarantineManifest)
+ skipTest(mochaContext, feature, scenario, quarantineManifest)
}
}
-function skipTest(context: string, testName: string, quarantineManifest?: [{ testcase: string, context: string }]) {
+function skipTest(mochaContext, context: string, testName: string, quarantineManifest?: [{ testcase: string, context: string }]) {
const shouldSkip = !!quarantineManifest?.find(
t => t?.testcase === testName && t?.context?.includes(context)
);
|
passing in the mocha context to the method works. thanks for your help. |
We have a plugin that will skip tests based on a dynmically generated json fille.
So in the previous implementation and cypress 9+ the following code would just skip the test.
How it's called in the suite
I think previously it was always doing a 'skip sync; abort execution' but cypress/cucumber-preprocessor would just skip the test. During the upgrade process this is now marking the skipped test as a failure.
So my question is, is there an alternate way we should be programmatically skipping tests. I was trying to see if there was some way i could add the ignore tag during this hook to the test and didn't see anything.
I know cypress fixed the sync skip isssue in version 9.2. and it was working on the previous version of cypress-cucumber-preprocessor we were on 4.1.2.
Versions
The text was updated successfully, but these errors were encountered: