I’m facing an issue where my Playwright test runs twice, even though I’ve configured the workers option to 1 in my Playwright config. Below is a snippet of my configuration:
timeout: 20 * 60 * 1000,
/* Run tests in files in parallel */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 1 : 0,
/* Opt out of parallel tests on CI. */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
Here’s an example of my test structure:
test.describe("First Step", () => {
test.beforeAll(async () => {
// Setup code
});
test("Single test", async () => {
// Test code
});
test.afterAll(async () => {
// Teardown code
});
});
However, when I run this single test, it shows the following in the console:
Running 2 tests using 1 worker
Even though I only have one test defined, Playwright identifies it as two tests.
What I’ve Tried
Ensured the workers option is set to 1 in the configuration.
Verified the test structure to confirm there’s only one test present.
Consulted ChatGPT, but the suggestions didn’t resolve the issue.
Goal
I need my test to execute only once, regardless of the worker count or configuration.
Has anyone encountered a similar issue? If so, how did you resolve it?