Skip to content
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

Bug: Error: Requiring @playwright/test second time #94

Closed
phramusca opened this issue Feb 23, 2024 · 18 comments
Closed

Bug: Error: Requiring @playwright/test second time #94

phramusca opened this issue Feb 23, 2024 · 18 comments
Labels
bug Something isn't working

Comments

@phramusca
Copy link

Given
playwright.config.ts:

import { defineConfig, devices } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';

const port = 8080;
const baseURL = `http://localhost:${port}`;

const testDir = defineBddConfig({
  paths: ['playwright/features/**/*.{feature,features}'],
  require: ['playwright/steps/**/*.*'],
});

/**
 * See https://playwright.dev/docs/test-configuration.
 */
export default defineConfig({
  testDir,
  /* 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 : 1,
  /* Opt out of parallel tests on CI. */
  fullyParallel: true,
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  reporter: 'html',
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    /* Base URL to use in actions like `await page.goto('/')`. */
    baseURL,
    headless: true,
    trace: 'on-first-retry',
  },
  workers: 7,

  /* Playwright propose a intern server, it will be launched when the test start */
  webServer: {
    command: 'npm run start',
    port,
    reuseExistingServer: !process.env.CI,
    timeout: 10 * 60 * 1000,
  },
  timeout: 5 * 60 * 1000,
  expect: {
    timeout: 2 * 60 * 1000,
  },
  /* Configure projects for major browsers */
  projects: [
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
      },
    },
    {
      name: 'firefox',
      use: {
        ...devices['Desktop Firefox'],
      },
    },
    {
      name: 'webkit',
      use: {
        ...devices['Desktop Safari'],
      },
    },
  ],
});

When
I try to run/debug tests in Visual Code with the "Playwright Test for VSCode" extension

Then
If I run in debug mode, it stops with this first error (then there are others if I continue):

Exception has occurred: Error
  at _A (C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:37:3587)
    at Function.statement (C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:37:2847)
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:41:1113
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:1:222
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:65:1678
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:1:222
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:65:38013
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:1:222
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:65:40602
    at C:\Users\xxxxxx\node_modules\playwright\lib\transform\babelBundleImpl.js:1:222

and in the end, I get this error in the test results console:

Error: Requiring @playwright/test second time, 
First:
Error: 
    at Object.<anonymous> (c:\Users\xxxxxx\node_modules\playwright\lib\index.js:77:33)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\Users\xxxxxx\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (c:\Users\xxxxxx\node_modules\playwright\test.js:17:13)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\Users\xxxxxx\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (c:\Users\xxxxxx\node_modules@playwright\test\index.js:17:18)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\Users\xxxxxx\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (c:\Users\xxxxxx\playwright.config.ts:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module.f._compile (c:\Users\xxxxxx\node_modules\playwright\lib\utilsBundleImpl.js:16:994)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .ts] (c:\Users\xxxxxx\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at requireOrImport (c:\Users\xxxxxx\node_modules\playwright\lib\transform\transform.js:182:20)
    at requireOrImportDefaultObject (c:\Users\xxxxxx\node_modules\playwright\lib\common\configLoader.js:126:53)
    at ConfigLoader.loadConfigFile (c:\Users\xxxxxx\node_modules\playwright\lib\common\configLoader.js:99:26)
    at Function.deserialize (c:\Users\xxxxxx\node_modules\playwright\lib\common\configLoader.js:93:51)
    at WorkerMain._loadIfNeeded (c:\Users\xxxxxx\node_modules\playwright\lib\worker\workerMain.js:178:53)
    at WorkerMain.runTestGroup (c:\Users\xxxxxx\node_modules\playwright\lib\worker\workerMain.js:187:18)
    at process.<anonymous> (c:\Users\xxxxxx\node_modules\playwright\lib\common\process.js:96:49)
    at process.emit (node:events:517:28)
    at emit (node:internal/child_process:944:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)


Second: 
    at Object.<anonymous> (c:\Users\xxxxxx\node_modules\@playwright\test\index.js:17:18)
    at Object.<anonymous> (c:\Users\xxxxxx\playwright.config.ts:1:1)
    at Object.<anonymous> (C:\Users\xxxxxx\node_modules\playwright\lib\index.js:72:11)
    at Object.<anonymous> (C:\Users\xxxxxx\node_modules\playwright\test.js:17:13)
    at Object.<anonymous> (C:\Users\xxxxxx\node_modules\@playwright\test\index.js:17:18)
    at Object.<anonymous> (C:\Users\xxxxxx\node_modules\playwright-bdd\src\run\bddFixtures.ts:1:1)
    at Object.<anonymous> (C:\Users\xxxxxx\node_modules\playwright-bdd\src\stepDefinitions\createBdd.ts:15:1)
    at Object.<anonymous> (C:\Users\xxxxxx\node_modules\playwright-bdd\src\index.ts:2:1)
    at Object.<anonymous> (C:\Users\xxxxxx\playwright\steps\acquisition.steps.ts:1:1)
    at tryRequire (c:\Users\xxxxxx\node_modules\@cucumber\cucumber\src\try_require.ts:9:12)
    at node_modules\@cucumber\cucumber\src\api\support.ts:27:40
    at getSupportCodeLibrary (c:\Users\xxxxxx\node_modules\@cucumber\cucumber\src\api\support.ts:27:16)
    at loadSupport (c:\Users\xxxxxx\node_modules\@cucumber\cucumber\src\api\load_support.ts:35:57)

But I expect
test to run/debug.

Note that the tests are running fine with npx bddgen && npx playwright test.

Isolated demo
Hard to make a demo since tests are included in a web react project that I cannot share easily. But I will try if really needed at one point.

Environment

Playwright-bdd environment info:

platform: win32
node: v18.19.0
playwright-bdd: v5.7.1
@playwright/test: v1.41.2
@cucumber/cucumber: v10.3.1
Playwright config file: playwright.config.ts
@phramusca phramusca added the bug Something isn't working label Feb 23, 2024
@vitalets
Copy link
Owner

Thanks for sharing this, I will check.

@phramusca
Copy link
Author

Hi @vitalets Did you have a chance to check ?

@vitalets
Copy link
Owner

vitalets commented Mar 9, 2024

Hi @vitalets Did you have a chance to check ?

Hi @phramusca
Tried to reproduce this on osx with exactly the same versions, but it works.
Could you try to remove node_modules, run npm install and then try again?
And re-try with the latest Playwright (1.42) and playwright-bdd (5.8)?

@adamwood-novafori
Copy link

I've come across this issue where I have two choices:

  1. My VSCode complains it can't find the datatable import from the cucumber package when I only have cucumber installed as a peer dependency but in reality it all runs fine and I just put up with a file being red.
  2. I add cucumber as a dev dependency, the file errors in the file go away but then I can't take advantage of the playwright VSCode plugin

@vitalets
Copy link
Owner

  1. My VSCode complains it can't find the datatable import from the cucumber package when I only have cucumber installed as a peer dependency but in reality it all runs fine and I just put up with a file being red.

Is it TypeScript error or Node.js runtime error? Could you share the full message?

  1. I add cucumber as a dev dependency, the file errors in the file go away but then I can't take advantage of the playwright VSCode plugin

After installing Cucumber you are getting Requiring @playwright/test second time error, right? Could you please clone playwright-bdd-example and run it in your VSCode?

@AdamJS123
Copy link

Confirming also receiving this issue. Running via a command line and no issue exists, whilst trying to run individual tests in the IDE to debug, the error appears.

package.json

{
  "name": "playwright-bdd-2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {},
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@playwright/test": "^1.42.1",
    "@types/node": "^20.11.28",
    "playwright-bdd": "^6.0.1"
  },
  "dependencies": {
    "allure-commandline": "^2.27.0",
    "allure-playwright": "^2.14.1",
    "cucumber": "^6.0.7",
    "dotenv": "^16.4.5"
  }
}

Error:

Error: Requiring @playwright/test second time, 
First:
Error: 
    at Object.<anonymous> (c:\Playwright BDD 2\node_modules\playwright\lib\index.js:69:33)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\Playwright BDD 2\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (c:\Playwright BDD 2\node_modules\playwright\test.js:17:13)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\Playwright BDD 2\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (c:\Playwright BDD 2\node_modules@playwright\test\index.js:17:18)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\Playwright BDD 2\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (c:\Playwright BDD 2\playwright.config.ts:8:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.f._compile (c:\Playwright BDD 2\node_modules\playwright\lib\utilsBundleImpl.js:16:994)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .ts] (c:\Playwright BDD 2\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at requireOrImport (c:\Playwright BDD 2\node_modules\playwright\lib\transform\transform.js:193:20)
    at loadUserConfig (c:\Playwright BDD 2\node_modules\playwright\lib\common\configLoader.js:96:83)
    at loadConfig (c:\Playwright BDD 2\node_modules\playwright\lib\common\configLoader.js:101:28)
    at deserializeConfig (c:\Playwright BDD 2\node_modules\playwright\lib\common\configLoader.js:91:24)
    at WorkerMain._loadIfNeeded (c:\Playwright BDD 2\node_modules\playwright\lib\worker\workerMain.js:188:62)
    at WorkerMain.runTestGroup (c:\Playwright BDD 2\node_modules\playwright\lib\worker\workerMain.js:197:18)
    at process.<anonymous> (c:\Playwright BDD 2\node_modules\playwright\lib\common\process.js:96:49)
    at process.emit (node:events:513:28)
    at emit (node:internal/child_process:937:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)


Second: 
    at Object.<anonymous> (c:\Playwright BDD 2\node_modules\@playwright\test\index.js:17:18)
    at Object.<anonymous> (c:\Playwright BDD 2\playwright.config.ts:8:1)
    at Object.<anonymous> (C:\Playwright BDD 2\node_modules\playwright\lib\index.js:64:11)
    at Object.<anonymous> (C:\Playwright BDD 2\node_modules\playwright\test.js:17:13)
    at Object.<anonymous> (C:\Playwright BDD 2\node_modules\@playwright\test\index.js:17:18)
    at Object.<anonymous> (C:\Playwright BDD 2\node_modules\playwright-bdd\src\run\bddFixtures.ts:1:1)
    at Object.<anonymous> (C:\Playwright BDD 2\node_modules\playwright-bdd\src\stepDefinitions\createBdd.ts:15:1)
    at Object.<anonymous> (C:\Playwright BDD 2\node_modules\playwright-bdd\src\index.ts:2:1)
    at Object.<anonymous> (C:\Playwright BDD 2\steps\homePage.ts:2:1)
    at tryRequire (c:\Playwright BDD 2\node_modules\@cucumber\cucumber\src\try_require.ts:9:12)
    at node_modules\@cucumber\cucumber\src\api\support.ts:27:40
    at getSupportCodeLibrary (c:\Playwright BDD 2\node_modules\@cucumber\cucumber\src\api\support.ts:27:16)
    at loadSupport (c:\Playwright BDD 2\node_modules\@cucumber\cucumber\src\api\load_support.ts:35:57)

@adamwood-novafori
Copy link

Just a TypeScript error on the import:
image

After installing Cucumber into the example project and running the test from the VSCode extention I can replicate the issue:
image

Side note: make sure you click the refresh icon in the extension once you've run bddgen

@vitalets
Copy link
Owner

@AdamJS123 @adamwood-novafori thanks, trying to reproduce.

@vitalets
Copy link
Owner

@AdamJS123 @adamwood-novafori could you clone playwright-bdd-example and try to reproduce this issue on it?

@adamwood-novafori
Copy link

The last screenshot in my previous message is from the example project:
Steps to reproduce:

  1. Open project
  2. npm i
  3. npm i -D @cucumber/cucumber
  4. bddgen
  5. Install the VS Code Playwright extension
  6. Click the small refresh button in the extension if the generated tests haven't been detected yet
  7. Then expand the tree of detected tests and click on the play button to execute a test from within the extension
  8. You should then see the message

Hope this helps

@JHGould5607
Copy link

Same issue with the steps above. Unable to execute the test from the test runner.

@vitalets
Copy link
Owner

@JHGould5607 could you also share error stack with paths of requiring Playwright?

@PavelGlebovAndritz
Copy link

I made some experiments:
when I copy (overwrite) all files from "playwright-bdd\examples\decorators" - repo to the "playwright-bdd-example" - all works as expected, I'm able to run test both from VSC Test Explorer and from command line.

@PavelGlebovAndritz
Copy link

How I install the example
Windows PowerShell
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

PS C:\rep\playwright-bdd-example> npm install

added 293 packages, and audited 294 packages in 10s

81 packages are looking for funding
run npm fund for details

found 0 vulnerabilities
PS C:\rep\playwright-bdd-example> npx playwright install
PS C:\rep\playwright-bdd-example> npm test

playwright-bdd-example@0.1.0 test
npx bddgen && npx playwright test

Running 1 test using 1 worker
1 passed (4.7s)
PS C:\rep\playwright-bdd-example> npm run report
npm ERR! Missing script: "report"
npm ERR!
npm ERR! Did you mean this?
npm ERR! npm repo # Open package repository page in the browser
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run

npm ERR! A complete log of this run can be found in: C:\Users\grzpav04\AppData\Local\npm-cache_logs\2024-04-08T10_48_25_198Z-debug-0.log
PS C:\rep\playwright-bdd-example>

@PavelGlebovAndritz
Copy link

When I run test in MS VSC using Test Explorer I got following output:

Running 1 test using 1 worker

  1. [chromium] › features\homepage.feature.spec.js:6:7 › Playwright Home Page › Check title ───────
Error: Requiring @playwright/test second time, 
First:
Error: 

   at ..\playwright.config.ts:1

> 1 | import { defineConfig, devices } from '@playwright/test';
    | ^
  2 | import { defineBddConfig, cucumberReporter } from 'playwright-bdd';
  3 |
  4 | const testDir = defineBddConfig({

    at Object.<anonymous> (c:\rep\playwright-bdd-example\node_modules\playwright\lib\index.js:69:33)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\rep\playwright-bdd-example\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (c:\rep\playwright-bdd-example\node_modules\playwright\test.js:17:13)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\rep\playwright-bdd-example\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (c:\rep\playwright-bdd-example\node_modules\@playwright\test\index.js:17:18)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .js] (c:\rep\playwright-bdd-example\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (c:\rep\playwright-bdd-example\playwright.config.ts:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module.f._compile (c:\rep\playwright-bdd-example\node_modules\playwright\lib\utilsBundleImpl.js:16:994)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.i.<computed>.ut._extensions.<computed> [as .ts] (c:\rep\playwright-bdd-example\node_modules\playwright\lib\utilsBundleImpl.js:16:1010)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at requireOrImport (c:\rep\playwright-bdd-example\node_modules\playwright\lib\transform\transform.js:193:20)
    at loadUserConfig (c:\rep\playwright-bdd-example\node_modules\playwright\lib\common\configLoader.js:96:83)
    at loadConfig (c:\rep\playwright-bdd-example\node_modules\playwright\lib\common\configLoader.js:101:28)
    at deserializeConfig (c:\rep\playwright-bdd-example\node_modules\playwright\lib\common\configLoader.js:91:24)
    at WorkerMain._loadIfNeeded (c:\rep\playwright-bdd-example\node_modules\playwright\lib\worker\workerMain.js:188:62)
    at WorkerMain.runTestGroup (c:\rep\playwright-bdd-example\node_modules\playwright\lib\worker\workerMain.js:197:18)
    at process.<anonymous> (c:\rep\playwright-bdd-example\node_modules\playwright\lib\common\process.js:96:49)
    at process.emit (node:events:517:28)
    at emit (node:internal/child_process:944:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Second: 
    at Object.<anonymous> (c:\rep\playwright-bdd-example\node_modules\@playwright\test\index.js:17:18)
    at Object.<anonymous> (c:\rep\playwright-bdd-example\playwright.config.ts:1:1)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\node_modules\playwright\lib\index.js:64:11)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\node_modules\playwright\test.js:17:13)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\node_modules\@playwright\test\index.js:17:18)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\run\bddFixtures.ts:1:1)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\steps\createBdd.ts:15:1)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\index.ts:2:1)
    at Object.<anonymous> (C:\rep\playwright-bdd-example\steps\fixtures.ts:1:1)
    at tryRequire (c:\rep\playwright-bdd-example\node_modules\@cucumber\cucumber\src\try_require.ts:9:12)
    at c:\rep\playwright-bdd-example\node_modules\@cucumber\cucumber\src\api\support.ts:27:40
    at getSupportCodeLibrary (c:\rep\playwright-bdd-example\node_modules\@cucumber\cucumber\src\api\support.ts:27:16)
    at loadSupport (c:\rep\playwright-bdd-example\node_modules\@cucumber\cucumber\src\api\load_support.ts:35:57)

Error in reporter Error: __bddData annotation is not found for test "Check title".
at TestCaseRun.extractBddData (c:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\reporter\cucumber\messagesBuilder\TestCaseRun.ts:77:13)
at new TestCaseRun (c:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\reporter\cucumber\messagesBuilder\TestCaseRun.ts:53:25)
at MessagesBuilder.onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\reporter\cucumber\messagesBuilder\Builder.ts:58:25)
at Object.onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\reporter\cucumber\messagesBuilder\index.ts:21:34)
at CucumberReporterAdapter.onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright-bdd\src\reporter\cucumber\index.ts:56:29)
at ReporterV2Wrapper.onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright\lib\reporters\reporterV2.js:87:150)
at c:\rep\playwright-bdd-example\node_modules\playwright\lib\reporters\multiplexer.js:47:65
at wrap (c:\rep\playwright-bdd-example\node_modules\playwright\lib\reporters\multiplexer.js:86:5)
at Multiplexer.onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright\lib\reporters\multiplexer.js:47:45)
at InternalReporter.onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright\lib\reporters\internalReporter.js:62:20)
at JobDispatcher._reportTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright\lib\runner\dispatcher.js:524:20)
at JobDispatcher._onTestEnd (c:\rep\playwright-bdd-example\node_modules\playwright\lib\runner\dispatcher.js:290:10)
at WorkerHost.emit (node:events:517:28)
at ChildProcess. (c:\rep\playwright-bdd-example\node_modules\playwright\lib\runner\processHost.js:105:16)
at ChildProcess.emit (node:events:517:28)
at emit (node:internal/child_process:944:14)
1 failed
[chromium] › features\homepage.feature.spec.js:6:7 › Playwright Home Page › Check title ────────

@vitalets
Copy link
Owner

vitalets commented Apr 9, 2024

I've made some investigation and released v6.3.0 that should possibly fix the issue.
Could you try it and share the result?

  1. Install latest playwright-bdd
npm i -D playwright-bdd@latest
  1. Change playwright.config.ts to use new steps field instead of require:
const testDir = defineBddConfig({
  paths: ['playwright/features/**/*.feature'],
-  require: ['playwright/steps/**'],
+  steps: ['playwright/steps/**'],
});
  1. Run tests as usual via CLI and via VSCode extension

@vitalets
Copy link
Owner

After #136 this issue should gone, b/c there will be single place of requiring Playwright.

@vitalets
Copy link
Owner

vitalets commented Jul 22, 2024

This error should gone as since v7 playwright-bdd does not use Cucumber for requiring steps.
Feel free to reopen in case of any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants