I have Test A in folder A1 and Test B in folder B1.
Using PlaywrightJS I would like to execute all of the tests inside folder B1 ONLY if everything inside folder A1 passes without any failures. The runner should stop if there are any failures. How can I do this?
2
Answers
It’s not a cool thing to write dependent tests, but if you need it, you can use Project dependencies
maxFailures: 1
But still – it’s better to use before/after hooks and test steps if you need to split test logic.
You can achieve this and have your tests independent at the same time by specifying a separate CLI command (e.g., npm script) for the tests in folder A (
run-tests-in-a
) and the tests in folder B (run-tests-in-b
) and then define a command that uses&&
CLI operator (run-tests-in-a && run-tests-in-b
).I understand that this is a bit more "hacky" than desired, but for a good reason. The general agreement is that tests should be written in an independent way (all tests make no assumptions about other tests), and so this behaviour of a conditional run cannot be a concern of the test framework.