microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
62.73k stars 3.38k forks source link

[Regression]: playwright vscode extension won't debug sample project error: Test did not expect test() to be called here. #30889

Closed stevenebutler closed 2 weeks ago

stevenebutler commented 2 weeks ago

Last Good Version

Extension version 1.1.2

First Bad Version

Extension version 1.1.3

Steps to reproduce

  1. Create a new folder and launch in code with playwright extension installed.
  2. Use CTRL-P: Test: Install Playwright and select a vanilla project with chromium
  3. Load the test lab tab and expand the testing.
  4. Attempt to run 'has title' test with the debug option

Expected behavior

I expect the test to run in the VsCode debugger allowing me to set breakpoints etc. This worked with previous version of playwright extension

Actual behavior

I see the following 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 (c:\dev\git\temp\temp2\node_modules\playwright\lib\common\testType.js:71:13)
    at TestTypeImpl._createTest (c:\dev\git\temp\temp2\node_modules\playwright\lib\common\testType.js:80:24)
    at node_modules\playwright\lib\transform\transform.js:256:12
    at Object.<anonymous> (c:\dev\git\temp\temp2\tests\example.spec.ts:3:5)

Additional context

Note this was first seen in my normal project so I tried with vanilla project to see if it was something about my project, but see the same error on the sample project tests.

VScode Extension version is 1.1.3

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 3.87 GB / 15.65 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.0.2 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.1.0 - C:\Program Files\nodejs\pnpm.CMD
    bun: 1.1.3 - ~\.bun\bin\bun.EXE
  IDEs:
    VSCode: 1.89.1 - C:\Users\sebut\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 5.2.21
  npmPackages:
    @playwright/test: ^1.44.0 => 1.44.0
mxschmitt commented 2 weeks ago

Please retry in v1.1.4 which we just released.

AlexandreBartie commented 2 weeks ago

Hi @mxschmitt ...

Playwright vscode extension v1.1.4 is running fine in debug mode again in my project. Thank you for fix this!

mxschmitt commented 2 weeks ago

I'll close this one, since this issue is resolved.

stevenebutler commented 2 weeks ago

Can confirm working for me now too. Thanks.