question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot run any Playwright test

See original GitHub issue

Context:

  • Playwright Version: 1.20.1
  • Operating System: Windows 10
  • Node.js version: 16.13.0]
  • Browser: All
  • Extra:

Describe the bug

A fresh installation of Playwright and attempting to run example spec produces this error:

$ npx playwright test

Running 0 test using 0 worker


Error: tests\example.spec.ts:5: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 dependenices in your package.json depends on @playwright/test.

   at ..\node_modules\@playwright\test\lib\util.js:198

  196 |
  197 | function errorWithLocation(location, message) {
> 198 |   return new Error(`${formatLocation(location)}: ${message}`);
      |          ^
  199 | }
  200 |
  201 | function expectType(receiver, type, matcherName) {

    at errorWithLocation (C:\projects\virtonomy\web_platform_main\e2e\node_modules\@playwright\test\lib\util.js:198:10)
    at TestTypeImpl._ensureCurrentSuite (C:\projects\virtonomy\web_platform_main\e2e\node_modules\@playwright\test\lib\testType.js:78:41)
    at TestTypeImpl._hook (C:\projects\virtonomy\web_platform_main\e2e\node_modules\@playwright\test\lib\testType.js:129:24)
    at Function.beforeEach (C:\projects\virtonomy\web_platform_main\e2e\node_modules\@playwright\test\lib\transform.js:253:12)
    at Object.<anonymous> (C:\projects\virtonomy\web_platform_main\e2e\tests\example.spec.ts:5:12)
    at Module._compile (C:\Projects\virtonomy\web_platform_main\e2e\node_modules\pirates\lib\index.js:136:24)
    at Object.newLoader (C:\Projects\virtonomy\web_platform_main\e2e\node_modules\pirates\lib\index.js:141:7)

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

To open last HTML report run:

  npx playwright show-report

package.json

{
  "name": "e2e",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {},
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@playwright/test": "^1.20.1"
  }
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:12

github_iconTop GitHub Comments

5reactions
fisnikbatushacommented, Apr 5, 2022

I also had this issue. In my case the problem was I was executing npx playwright test from root directory and not inside tests repository.

3reactions
prushforthcommented, Aug 7, 2022

I’m also using git bash, and in my case I had CDed into a directory with incorrect casing, e.g. myplaywrightdir instead of myPlaywrightDir. Going up a directory and then cding back down into the dir with the correct casing fixed the problem for me.

I encountered this problem when I used lowercase paths to cd with powershell to the project directory. When I navigated from c:\ into the full directory path with the correct casing, the problem disappeared.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run the playwright tests - Stack Overflow
I am trying to run playwright test from the below location, but it shows the message npm install -D @playwright/test and unable to...
Read more >
playwright - npm
The easiest way to get started with Playwright Test is to run the init command. # Run from your project's root directory npm...
Read more >
Playwright Beginner Tutorial 3 | How to run tests - YouTube
ALL FREE COURSES ▻ https://automationstepbystep.com/ ▭ ASK RAGHAV ▻ https://bit.ly/2CoJGWf QUIZ - https://forms.gle/TXRXbM8URRXppwem6▭▭ ...
Read more >
Playwright Test for VSCode - Visual Studio Marketplace
You can also choose to add a GitHub Action so that you can easily run tests on Continuous Integration on every pull request...
Read more >
Writing your first Playwright test - Tim Deschryver
Setting up playwright and "writing" a first test only takes a few minutes! ... it doesn't start a new application when it's already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found