playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] possible bug when test cannot be run from vscode

Open LadaVarga opened this issue 3 years ago • 2 comments

Context:

  • Playwright Version: 1.26
  • Operating System: Windows 11
  • Node.js version: [e.g. 12.22, 14.6]
  • Visual Studio Code version: Version: 1.71.2 (system setup) Commit: 74b1f979648cc44d385a2286793c226e611f59e7 Date: 2022-09-14T21:03:37.738Z Electron: 19.0.12 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.22000 Sandboxed: No
  • Playwright for VSCode extension version: [e.g. 1.2.3]
  • Browser: [e.g. All, Chromium, Firefox, WebKit]
  • Extra: [any specific details about your environment]

Describe the bug

I have problem with running tests from VScode plugin from test window (run and debug behave same). Till version 1.26 it was ok, I used version 1.21.1. I simple run npx playwirht install to install the latest + I tried reinstall VScode plugin too. If I use npx playwright test it works properly.

DEBUG CONSOLE C:\Program Files\nodejs\node.exe .\node_modules\playwright-core\lib\cli\cli test -c playwright.config.ts --headed --project=chromium --repeat-each 1 --retries 0 --timeout 0 --workers 1

Running 0 tests using 0 workers

Error: tests\bid-board-integrated.spec.ts:91:16: 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 ..\node_modules@playwright\test\lib\util.js:216

    214 | 215 | function errorWithLocation(location, message) {

216 | return new Error(${formatLocation(location)}: ${message}); | ^ 217 | } 218 | 219 | function expectTypes(receiver, types, matcherName) {

at errorWithLocation (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\util.js:216:10)
at TestTypeImpl._ensureCurrentSuite (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\testType.js:80:41)
at TestTypeImpl._createTest (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\testType.js:89:24)
at C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\transform.js:267:12
at Object.<anonymous> (C:\Git\esticom-frontend\E2E-Playwright\tests\bid-board-integrated.spec.ts:91:16)

Error: tests\bid-board.spec.ts:11:12: Playwright Test did not expect test.beforeEach() to be called here. Most common reasons include:

  • You are calling test.beforeEach() in a configuration file.

  • You are calling test.beforeEach() 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 ..\node_modules@playwright\test\lib\util.js:216

    214 | 215 | function errorWithLocation(location, message) {

216 | return new Error(${formatLocation(location)}: ${message}); | ^ 217 | } 218 | 219 | function expectTypes(receiver, types, matcherName) {

at errorWithLocation (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\util.js:216:10)
at TestTypeImpl._ensureCurrentSuite (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\testType.js:80:41)
at TestTypeImpl._hook (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\testType.js:148:24)
at Function.beforeEach (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\transform.js:267:12)
at Object.<anonymous> (C:\Git\esticom-frontend\E2E-Playwright\tests\bid-board.spec.ts:11:12)

Error: tests\staging.spec.ts:9:12: Playwright Test did not expect test.beforeEach() to be called here. Most common reasons include:

  • You are calling test.beforeEach() in a configuration file.

  • You are calling test.beforeEach() 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 ..\node_modules@playwright\test\lib\util.js:216

    214 | 215 | function errorWithLocation(location, message) {

216 | return new Error(${formatLocation(location)}: ${message}); | ^ 217 | } 218 | 219 | function expectTypes(receiver, types, matcherName) {

at errorWithLocation (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\util.js:216:10)
at TestTypeImpl._ensureCurrentSuite (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\testType.js:80:41)
at TestTypeImpl._hook (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\testType.js:148:24)
at Function.beforeEach (C:\Git\esticom-frontend\E2E-Playwright\node_modules\@playwright\test\lib\transform.js:267:12)
at Object.<anonymous> (C:\Git\esticom-frontend\E2E-Playwright\tests\staging.spec.ts:9:12)

================= no tests found.

3 errors were not a part of any test, see above for details

LadaVarga avatar Sep 21 '22 15:09 LadaVarga

If I downgrade to previous version 1.21.1 the VScode plugin works properly(I need install older chromium) and I can debug and run tests from VScode.

LadaVarga avatar Sep 21 '22 15:09 LadaVarga

Can you share your package-lock.json as well as output of the following?

npm ls playwright
npm ls playwright-core
npm ls @playwright/test

rwoll avatar Sep 21 '22 16:09 rwoll

Folding into https://github.com/microsoft/playwright/issues/17500.

rwoll avatar Sep 21 '22 16:09 rwoll