Rayrun
← Back to Discord Forum

VS Code - Playwright test for VS Code extension - it does not show tests

martinh3309posted in #help-playwright
Open in Discord
martinh3309

Hello! I have recently installed VS Code - Playwright test for VS Code extension. If I have opened my project repository it does not show any tests. It says "No tests have been found in this workspace yet" . I use playwright Version 1.35.1 and node v18.16.0. Anyone has any ideas? I want see the tests.

image.png

This thread is trying to answer question "Why does the VS Code - Playwright test for VS Code extension not show any tests?"

48 replies
codefreak81
codefreak81

Is your test directory named specs or tests? usually by default when you create the project the directory is called tests.

martinh3309

My tests are in \test\playwright\specs\connext\e2e - so e2e

Check testDir in playwright config

Can you try just adding a new project from scratch to see if vscode and the extension are working from the examples. This will rule out any issues there. In your screenshot you have testDir: './specs' did you override this in your projects configuration? Make sure this is correct in your setup. Also, if you are using testMatch as a setting that that is correct as well. Finally, ensure that you have no errors in compilation, that will cause an issue as well.

Was going to suggest what NZCarnage said earlier, just got distracted. Only other point, double check the docs your platform is supported.. sure PW 1.35.1 && node 18.16, why not the OS?

martinh3309
@zorro: there I got */ const config: PlaywrightTestConfig = { globalSetup: require.resolve('./global-setup'), testDir: './specs',

there I got */ const config: PlaywrightTestConfig = { globalSetup: require.resolve('./global-setup'), testDir: './specs',

martinh3309
@nzcarnage: I started a new project recently according to the tutorial and there it works properly:

I started a new project recently according to the tutorial and there it works properly:

image.png
martinh3309
@d3333333: OS is Windows 10 and definitely is supported

OS is Windows 10 and definitely is supported

martinh3309
@nzcarnage: Yes I think so. The default is /tests

Yes I think so. The default is /tests

Your testDir is based on the root of your project I have D:\RepoName\src\tests\e2e so my root is the repo folder so my testDir is ./src/tests/e2e I hope that helps

I have the same issue as well Martin

My tests are in C:\Users\FS\Desktop\Lis\tests\e2e

I had this issue too until recently & tried all sorts of things to fix. I had some other network type issues as well (logging in & settings sync) with vscode & so focused on the vscode install. Once I upgraded vscode & reinstalled from on network it started working. It didn't fix my other issues however 🙃

May be it will help if you post the directory structure. This tests dir needs to be relative to the config file.

martinh3309

My tests are mainly in: C:\Users\XXXXX\XXXXX\YYYYY\test\playwright\specs\YYYYY\e2e\charts-universal.spec.ts. I have also 2 tests here: in in this folder: C:\Users\XXXX\YYYYY-YYYY\ZZZ\test\playwright\tests\example.spec.ts

martinh3309

In playwright I got: testDir: './specs',. Despite of that, it does not work.

@zorro: I am missing a config file in the project, that might be the problem ?

I am missing a config file in the project, that might be the problem ?

martinh3309

there is config file: playwright.config.ts in playwright folder

martinh3309

@zorro @nzcarnage anyone has any ideas how to fix this?

martinh3309

I tried various options but nothing works for ome

@martinh3309 Is specs relative to the project directory? As in is the testDir specified in config at same level as playwright.config.ts?

Can you post directory tree structure?

Yeah, your dir tree, config file and where in the dir tree your config is will be helpful. Also, where is your terminal starting from when In VS code. I don't run under users, so I will need to create a project under that folder, could be something I am missing when trying to reproduce it.

I'm curious if the VS Code Extension was updated, if all was working before, this would throw a wrench into the works... I'm using "Playwright Test for VSCode v1.0.13" check your version...

martinh3309

@zorro @nzcarnage @d3333333

martinh3309

MY PROJECT DIRECTORY IS: C:\Users\XXXX\OPERATION-XXL\operator.app>

PLAYWRIGHT CONFIG IS IN: C:\Users\XXXX\OPERATION-XXL\operator.app\test\playwright\playwright.config.ts

My E2E test cases are in: C:\Users\XXXX\OPERATION-XXL\operator.app\test\playwright\specs\connext\e2e

MY TERMINAL STARTS WITH: C:\Users\XXXX\OPERATION-XXL\operator.app>

AT THE MOMENT MY PLAYWRIGHT CONFIG IS: testDir: './specs/connext/e2e',

PS: When I try to new project where I also have playwright, there it works OK.

martinh3309
@d3333333: Yes I use the latest version.

Yes I use the latest version.

Does the npx playwright test command work?

If yes then it's issue with vs code

It seems others have reported similar issues, possible solution is restarting vscode, reload window and how you launch it.

Try clicking record new and see where it create the file

But most likely an issue with vscode

Or better yet. Create a simple clean new project form vs code, Should have two sample tests and that should all work... Does it? Follow the install as Debbie shows in this video... https://playwright.dev/docs/getting-started-vscode

Would assert if you follow that and it fails then you have a bug you can file...

While generally "C:\Users" is not the best place to be working it can inject issues with permissions. Create a folder in tmp "c:\tmp\WorkFromHere" not under your 'users' folder.

martinh3309

@zorro it does not I am getting: Error: ENOENT: no such file or directory, open 'debug.json' at Object.openSync (node:fs:601:3) at readFileSync (node:fs:469:35) at Object.<anonymous> (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\playwright.config.ts:18:38) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module.f._compile (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\lib\utilsBundleImpl.js:16:994) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Object.i.<computed>.ut._extensions.<computed> (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\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:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\lib\transform\transform.js:172:20) at requireOrImportDefaultObject (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\lib\common\configLoader.js:83:53) at ConfigLoader.loadConfigFile (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\lib\common\configLoader.js:56:26) at runTests (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\lib\cli.js:120:55) at qr.<anonymous> (C:\Users\thoang\OPERATOR-XXL\operator.app\test\playwright\node_modules@playwright\test\lib\cli.js:40:7) { errno: -4058, syscall: 'open', code: 'ENOENT', path: 'debug.json' }

martinh3309

@zorro I tried restarting but it did not help. Sounds like a problem with configuration rather than VS CODE. If I start a new project from the scratch, there it works. It does not work on my work project.

martinh3309
@dand33: yes new project from the scratch works with clean repository. But it must be working on my work project as well thats where we use playwright

yes new project from the scratch works with clean repository. But it must be working on my work project as well thats where we use playwright

Try running those tests individually?

Just have testDir: "./specs" in config?

Not sure if this is related to permissions issues, is this other project where playwright works on the same machine under same User dir?

Either that or this is some issue with npm

Even if you run npx playwright test without playwright.config.ts, it will prompt to freshly install playwright, so it did find it. Could be some permissions issue or issue with npm, I am not sure.

Or it could be that npx is trying to log the error to debug.json but it's failing due to permissions.

Not really sure, haven't worked with node ecosystem that much.

Try specifying config file manually with --config

If it works in a clean/new project, would assert PW is fine then. So as you mention something about your configuration is effecting it. Any 3rd party tools or packages, pnpm and not npm, Errors/problems noted in VS Code for your project, found some errors may appear, even had it happen last night valid javascript but had unknown members on an object and something failed to parse, and no test showed up. I could right mouse in the file and "Debug test at cursor" and it ran. While the error "debug.json" hmmm who's file is that, i all my PW projects their is no such file... Think that is your issue...

I know it won't help resolve the problem but if it's the ability to see certain tests by tags for e.g. that you're missing, I've found searching in all files gives me the same result as searching in test explorer. Annoying as it is that it's not working the same can be achieved with Ctrl+f

@martinh3309 This is what I did:

  1. Created a folder under my user account \OPERATION-XXL\operator.app\test\playwright
  2. opened vscode to the playwright folder
  3. ran npm init playwright@latest and told it to place tests in specs\connext\e2e
  4. ran npx playwright test to verify things are working and verifying the Test Explorer. (I did change testDir from ./specs\connext\e2e to ./specs/connext/e2e should not have impacted things.)
  5. Test explorer found tests in specs\connext\e2e folder
  6. closed vscode and reopened to \OPERATION-XXL\operator.app>
  7. opened test explorer and it picked up the full path to my test\playwright\specs\connext\e2e

So things are working for me in the above scenario, as you can see I am running the latest playwright 1.36.0, vs code latest 1.80.0 and vs code extension 1.0.13

image.png

Let me know if you did something different, also interested if you do a similar scenario from the above steps will it work for you in the same manner. Sorry was not able to find the smoking gun here, it just worked for me. Was thinking possible permissions issue would pop up being under the Users folder, but nothing strange occurred.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.