admin管理员组文章数量:1355996
I have a lot of tests in my project, a lot of them have been running in parallel, which is completely fine with me. However, I have a few tests in a specific folder that need to run in order because each test depends on the other, how would I go about making only that specific test run sequentially?
Say I run a few tests on my /onboard
route, this route redirects them to the /onboard/verify
when the user successfully creates an account, the verify route would make them verify the OTP code sent to the email, and then the /onboard/questionnaire
would fill out some questionnaire information for this account.
Mind you the tests are split up in different files all in the same folder
I'm using Playwright for my NextJS application
I have a lot of tests in my project, a lot of them have been running in parallel, which is completely fine with me. However, I have a few tests in a specific folder that need to run in order because each test depends on the other, how would I go about making only that specific test run sequentially?
Say I run a few tests on my /onboard
route, this route redirects them to the /onboard/verify
when the user successfully creates an account, the verify route would make them verify the OTP code sent to the email, and then the /onboard/questionnaire
would fill out some questionnaire information for this account.
Mind you the tests are split up in different files all in the same folder
I'm using Playwright for my NextJS application
Share Improve this question edited yesterday Pi. 1597 bronze badges asked Mar 28 at 19:28 XyeutXyeut 534 bronze badges 02 Answers
Reset to default 7Please refer to Serial Mode
Using mode: serial
will ensure all tests in the spec are run and retried together and in order.
Note test.describe.serial -
⚠️ DISCOURAGED
See test.describe.configure() for the preferred way of configuring the execution mode.
import { test } from '@playwright/test';
test.describe.configure({ mode: 'serial' });
test.beforeAll(async () => { /* ... */ });
test('first good', async ({ page }) => { /* ... */ });
test('second flaky', async ({ page }) => { /* ... */ });
test('third good', async ({ page }) => { /* ... */ });
Mind you the tests are split up in different files all in the same folder
You may find it easier to manage the sequential tests by using a single spec, but that has disadvantages with a long testing story.
The Project configuration in playwright.config.ts
has the dependencies concept, with that you can break up a sequential testing story and use the dependencies
key in projects to force the correct order (and configure serial mode within individual specs).
Dependencies are a list of projects that need to run before the tests in another project run. They can be useful for configuring the global setup actions so that one project depends on this running first.
The advantage of dependencies is you are not constrained to a particular folder structure.
This is the example code from the docs:
import { defineConfig } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'setup',
testMatch: '**/*.setup.ts',
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
dependencies: ['setup'],
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
dependencies: ['setup'],
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
dependencies: ['setup'],
},
],
});
Simply run through command prompt like below:
npx playwright test tests/my-sequential-folder --workers=1
本文标签:
版权声明:本文标题:next.js - Run specific tests in folder sequentially while all other tests in parallel with Playwright - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744017191a2576546.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论