'Playwright using JS

I am facing issue with configuration of playwright. Test scenarios is placed under the project directory but during execution it shows no tests found

  1. npm i -D @playwright/test
  2. npx playwright install
  3. Execution : npx playwright testScreenshot attached


Solution 1:[1]

You need to rename the filename to the first.test.js or add the testMatch property in the configuration file.

testMatch - Glob patterns or regular expressions that match test files.

Because by default, Playwright Test runs .(test|spec)

Solution 2:[2]

According to playwright.dev/js you should try naming your files "name.spec.js" or "name.spec.ts". https://playwright.dev/docs/intro

Alternatively, you can check your config to make sure that your test command is running files in the correct folder. This would be located in your playwright.config.js or playwright.config.ts file. Its name would be testDir: 'folderName',

If you dont have a config you can create it in the parent folder with the name of playwright.config.ts or js. Then paste the sample codes they give you on their dev site. https://playwright.dev/docs/test-configuration#global-configuration

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yevhen Laichenkov
Solution 2 Nuka