Closed kishkk84 closed 4 days ago
@kishkk84
Hello @vitalets I've the same issue after upgrading playwright to "playwright": "^1.45.3",
and after upgrading playwright-bdd to "playwright-bdd": "^7.1.0",
I changed only this :
const testDir = defineBddConfig({
tags: 'not @ignore',
features: 'tests/*/*.feature',
steps: 'tests/*/*/*.ts'
});
and I just tried to launch npx bddgen && npx playwright test --ui
My package.json looks like that now :
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@types/node": "^22.0.0",
"dotenv": "^16.4.5",
"fs-extra": "^11.2.0",
"moment": "^2.30.1",
"playwright": "^1.45.3",
"playwright-bdd": "^7.1.0",
"playwright-slack-report": "^1.1.81",
"reflect-metadata": "^0.2.2",
"ts-node": "^10.9.2"
}
My playwright config looks like that :
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
import { defineBddConfig } from 'playwright-bdd';
dotenv.config();
const testDir = defineBddConfig({
tags: 'not @ignore',
features: 'tests/*/*.feature',
steps: 'tests/*/*/*.ts'
});
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir,
/* Run tests in files in parallel */
fullyParallel: true,
/* 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 ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 4 : 5,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
[
'./node_modules/playwright-slack-report/dist/src/SlackReporter.js',
{
sendResults: 'off'
}
],
['blob'], ['list']
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL: 'https://someUrl.com',
trace: 'off',
navigationTimeout: 60000,
actionTimeout: 10000,
screenshot: 'only-on-failure'
},
expect: {
timeout: 30000
},
timeout: 480000,
/* Configure projects for major browsers */
projects: [
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
testDir: './setup'
},
{
name: 'chrome_pre-prod',
use: {
...devices['Desktop Chrome'],
contextOptions: {
screen: {
width: 1920,
height: 1024
}
},
viewport: {
width: 1920,
height: 1024
},
storageState: '.auth/storageState.json'
},
dependencies: ['setup']
}
]
});
Is it enough for you ?
Edit : I'm pretty sure it's not linked to playwright-bdd
as when downgrading playwright
version to 1.44.0
it works fine.
My error :
Error: Playwright Test did not expect test() to be called here.
Most common reasons include:
- You are calling test() in a configuration file.
- You are calling test() in a file that is imported by the configuration file.
- You have two different versions of @playwright/test. This usually happens
when one of the dependencies in your package.json depends on @playwright/test.
at TestTypeImpl._currentSuite (/Users/IdeaProjects/poc-playwright/node_modules/@playwright/test/node_modules/playwright/lib/common/testType.js:71:13)
at TestTypeImpl._createTest (/Users/IdeaProjects/poc-playwright/node_modules/@playwright/test/node_modules/playwright/lib/common/testType.js:80:24)
at /Users/IdeaProjects/poc-playwright/node_modules/@playwright/test/node_modules/playwright/lib/transform/transform.js:256:12
at Object.<anonymous> (/Users/IdeaProjects/poc-playwright/setup/auth.setup.ts:6:6)
And my auth.setup.ts
file :
import { test as setup } from '@playwright/test';
import { utils } from '../model/Utils/utils';
const authFile = '.auth/storageState.json';
setup('authenticate', async ({ page }) => {
const utils = new utils(page);
await utils.authenticate();
await utils.assertNoPopUpPresent();
await page.context().storageState({ path: authFile });
});
Another one base on .features-gen folder :
Error: Playwright Test did not expect test.describe() to be called here.
Most common reasons include:
- You are calling test.describe() in a configuration file.
- You are calling test.describe() in a file that is imported by the configuration file.
- You have two different versions of @playwright/test. This usually happens
when one of the dependencies in your package.json depends on @playwright/test.
at TestTypeImpl._currentSuite (/Users/IdeaProjects/poc-playwright/node_modules/@playwright/test/node_modules/playwright/lib/common/testType.js:71:13)
at TestTypeImpl._describe (/Users/IdeaProjects/poc-playwright/node_modules/@playwright/test/node_modules/playwright/lib/common/testType.js:104:24)
at Function.describe (/Users/IdeaProjects/poc-playwright/node_modules/@playwright/test/node_modules/playwright/lib/transform/transform.js:256:12)
at Object.<anonymous> (/Users/IdeaProjects/poc-playwright/.features-gen/tests/Test/Test.feature.spec.js:4:6)
/** Generated from: tests/Test/Test.feature */
import { test } from "playwright-bdd";
test.describe("Test Test functionality", () => {
test("A test", async ({ Given, page, When, Then }) => {
await Given("I am logged in", null, { page });
await When("I am in \"Test\" section", null, { page });
await Then("all created tests should be displayed in a table list", null, { page });
});
test.describe("A small Test <number>", () => {
test("A small Test 1", async ({ Given, page, When, And, Then }) => {
await Given("I am logged in", null, { page });
await When("I am in \"Test\" section", null, { page });
await And("I types a search by \"name\" on the search field", null, { page });
await Then("the list should be auto-refreshed based on the search request", null, { page });
});
test("A small Test 2", async ({ Given, page, When, And, Then }) => {
await Given("I am logged in", null, { page });
await When("I am in \"Test\" section", null, { page });
await And("I types a search by \"url\" on the search field", null, { page });
await Then("the list should be auto-refreshed based on the search request", null, { page });
});
});
});
// == technical section ==
test.use({
$test: ({}, use) => use(test),
$uri: ({}, use) => use("tests/Test/Test.feature"),
$bddFileMeta: ({}, use) => use(bddFileMeta),
});
const bddFileMeta = {
"A test": {"pickleLocation":"3:3"},
"A small Test <number>|A small Test 1": {"pickleLocation":"16:7"},
"A small Test <number>|A small Test 2": {"pickleLocation":"17:7"},
};
I see in devDependencies "playwright": "^1.45.3",
not @playwright/test
.
Could you try the following:
npm uninstall playwright
npm install -D @playwright/test
Hello @vitalets it seem to works better ! But for my own knowledge, what is the difference? (Given that it worked in version 1.44)
playwright
package is just a browser manipulation library, while @playwright/test
is playwright
+ test runner.
Here are more details on that: https://playwright.dev/docs/library
I am seeing this error any idea how to resolve it?
Error
base.fixture.ts
Playwright.config.ts