Closed SamShot81 closed 1 day ago
Hey, try something like this
import { Selector } from 'testcafe';
let shouldSkip = false;
fixture `My Fixture`
.beforeEach(async t => {
if (shouldSkip) {
await t.skip();
}
})
.afterEach(async t => {
// Check if the current test failed
const testFailed = t.testRun.errs.length > 0;
if (testFailed) {
shouldSkip = true;
}
});
test('Test 1', async t => {
// Your test logic for Test 1
// Uncomment this line to simulate a test failure
// throw new Error("Simulated failure in Test 1");
});
test('Test 2', async t => {
// This test will be skipped if Test 1 fails
// Your test logic for Test 2
});
test('Test 3', async t => {
// This test will also be skipped if any previous test in the fixture fails
// Your test logic for Test 3
});
In TestCafe, you cannot skip a test from inside or use the beforeEach hook for this purpose because the test queue is created at the compilation stage.
Unfortunately, we cannot take this enhancement into work since we are currently focused on other tasks.
What is your Scenario?
I am working with a situation where I have the following scenario/steps to Test 1) Create 2) Edit 3) Delete
I have the test cases ready but I need a way to skip the Edit and Delete TCs if the Create TC fails. In other words I need to chain them together so the system understands that if Create was not successful then skip the Edit and Delete test cases (Conditional Skipping).
Is it possible with any existing process like hooks/test Context?
Is there any logic I can use to make this happen?
Thanks in Advance.
Expecting something like below
What are you suggesting?
What alternatives have you considered?
Could not find any material regarding this in testcafe documentation.
Additional context
No response