-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Is it possible to apply a test.use() for a particular test #28
Comments
Let me think about it |
Btw, in Playwright if you call test("test 1", async ({ page }) => { ... });
test.use({ viewport: { width: 800, height: 600 }});
test("test 2", async ({ page }) => { ... }); Both To execute one test in different viewport we could use fixtures-overrides: const test = base.extend({
viewport: async ({ viewport }, use, testInfo) => {
if (testInfo.title.includes('(800x600)')) {
viewport = { width: 800, height: 600 };
}
await use(viewport);
}
});
test("test 1", async ({ page }) => { ... });
test("test 2 (800x600)", async ({ page }) => { ... }); Here only With playwright-bdd we can use exactly the same approach with fixtures overrides. For example in import { test as base } from 'playwright-bdd';
export const test = base.extend({
viewport: async ({ viewport }, use, testInfo) => {
if (testInfo.title.includes('(800x600)')) { // <- can also use testInfo.titlePath to apply 800x600 to whole feature
viewport = { width: 800, height: 600 };
}
await use(viewport)
}
}); And then in config: const testDir = defineBddConfig({
importTestFrom: 'fixtures.ts',
// ...
}); @NikkTod could you check and let me know does it works for you? Note: Feature: Playwright site
@tablet
Scenario: Check title
Given I open url "https://playwright.dev"
When I click link "Get started"
Then I see in title "Playwright"
import { test as base } from 'playwright-bdd';
export const test = base.extend({
viewport: async ({ viewport, $tags }, use) => {
if ($tags.includes('@tablet')) {
viewport = { width: 800, height: 600 };
}
await use(viewport)
}
}); |
@vitalets actually you are right, I kind of misslead you. Good example on the feature override, I actually created for me a new project within the playwright.config file, but I also checked your suggestion and it is working as expected, thank you I will close that ticket. I very much like your suggestion for custum tags, looking forward to see it implemented, as I think it will help us a lot. |
You are welcome :) |
Added this question to FAQ. |
For example I want one of the test in a feature file to be executed with diffeent screen size, so in playwright I would apply:
test.use({viewport: {width: 800, height: 600}})
How would we do it with playwright-bdd?
The text was updated successfully, but these errors were encountered: