playwright
playwright copied to clipboard
[Feature] Add annotations for test.step similar to test
Currently skip option is available on test case level(https://playwright.dev/docs/test-annotations)
But there is no skip /similar annotations in test step level
Expected
test.step.skip test.step.only test.step.fail (https://github.com/microsoft/playwright/issues/10033)
Sometimes there may be a reason to skip a step, especially if that step is just for checking content, i.e. test.expect
For example
test("update profile", async function () {
test.step("update");
test.step.skip("check part A"); // part A currently disabled due to frontend bugs
test.step("check part B");
})
it's better than commenting out the step
I have a situation where one test step works on chromium and firefox but fails on WebKit due to the latest trunk build for the playwright WebKit browser. I would like to skip the test step just for WebKit and only that step since the other ones work fine for all of the browsers. Having annotations added to the test.step() level and not just the parent level test() method would substantially help to organize and provide correct results for reporting without having to add if/else conditionals all over the test file.
test.step.skip in reports:
Total steps: x
Skipped: y
❤️
And my usecase
await test.step('#4 - type unique keyword(BUG:EP-26957)', async () => {
const uniqueKeyword = subForm2.NAME;
await formScreen.subformDropdownMenuSearchInput.fill(uniqueKeyword);
// await expect.soft(formScreen.subformDropdownMenuItem).toHaveText(uniqueKeyword);// restore after fixing https://company.atlassian.net/browse/EP-26957
});
Sometimes there may be a reason to skip a step, especially if that step is just for checking content, i.e. test.expect
For example
test("update profile", async function () { test.step("update"); test.step.skip("check part A"); // part A currently disabled due to frontend bugs test.step("check part B"); })
it's better than commenting out the step
Totally agree
Adding my vote! I just went to skip a new test step and discovered that there was no such option. I just expected it would be there, its intuitive that it would exist.
This is definitely a valuable feature. My use case is for a step that does not work across all test environments at the moment so need to skip it to avoid unnecessary test failures.
I have been recently working to improve our end-to-end tests at my company, and a lot of good work's been done. Only thing I am missing is having the ability to just test.step.skip
instead of commenting it out.
I reckon there has to be a temporary way to be able to implement it ourselves, till Playwright officially adds it. I am not looking for being able to pass a condition into test.step like we have for test.
Just adding a .skip
should skip that step without supplying a condition.
Another use case: We use skipped tests in our daily smoke testing reporting to see which tests we know are currently disabled (because they found a bug that is currently being worked on, and we disable the tests to not have red pipelines all the times, until the bug is fixed).
It would be super helpful to only disable some steps of a test that perform the checks for the things that are currently broken, have the rest of the test still being executed, and getting this "test X step Y was skipped" message in the reports
Another +1 for this please
Use case: We have different product types that we define in env variables and pass to skip tests:
PRODUCT_TYPE=foo npx playwright test
Having an option to conditionally skip a step would be really helpful. Such as:
await test.step('My test title', async () => {
step.skip(process.env.PRODUCT_TYPE === 'foo');
await testPage.myTestName();
});
Thanks :)
+1 For this request, would be super useful.
+1 very handy ask, I do not want to skip the entire test just skip the test.step that is looking for a specific context in the whole test aka, a button can have 4 different classes, I'd like to test.step each class scenario but skip it if on an entire grid of which there are many assigned classes, if 1/4 classes are not present, skip the test.step targeting them. it would be handy
This would be super helpful so voting this to get added as well.
another +1, would be really helpful
another +1, would be really helpful if we can skip a test with or without condition
+1
+1 this is needed.
+1
+1
+1
+1
Please, lets just add 👍 reaction to the first message.
Could you help me understand why the following notation is not solving this request?
condition && await test.step('my step', async () => {
...
});
Could you help me understand why the following notation is not solving this request?
That approach is viable and something I've personally used but I do think a dedicated method does provide a bit cleaner syntax. I wonder what the motivations for test.skip
originally were, I am sure there would be some crossover here.
On another note, that kind of conditional logic is also seemingly against recommend best practices and flags warnings for me. However I am aware that's a bit of a "six of one, half a dozen of the other" scenario.
@pavelfeldman
condition && await test.step('my step', async () => {
...
});
will not show in reports. Visibility over what was run is one of the good characteristics of Playwright. If something was skipped, reports should reflect it.
@quoid
I wonder what the motivations for
test.skip
originally were
Just like test.skip
gives finer control over which tests execute based on certain conditions that can be evaluated at runtime. In the same way, step.skip
will give finer control over which steps contribute towards the test based on some conditions that can be evaluated at runtime.
There are times where one may want to skip a step from executing when run in a different (but similar) environment. Some steps may not be applicable or become additional steps depending upon the execution environment. I would not want to maintain two copies of similar test with minor differences.