saurabh bhattacharya
saurabh bhattacharya

Reputation: 49

"No tests found" message on console on having tests file in the directory

I am facing an 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 test

Screenshot attached

Upvotes: 3

Views: 2065

Answers (3)

Nuka
Nuka

Reputation: 11

According to playwright.dev/js, you should try naming your files "name.spec.js" or "name.spec.ts". See Installation.

Alternatively, you can check your configuration 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 don’t have a configuration 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 development site. See Test configuration.

Upvotes: -1

Chandrakanta
Chandrakanta

Reputation: 1

To ensure your Playwright configuration points to the correct directory for your test files, you'll need to modify the playwright.config.js file. Here's how you can do it:

1- Locate the playwright.config.js file in your project directory.

2- Open the file and go to line 14, where you should see the configuration property testDir: './tests',.

3- Replace './tests' with the path to the folder containing your test files.

For example, if your test files are located in a folder named myTests, update the line to:

Upvotes: -1

Yevhen Laichenkov
Yevhen Laichenkov

Reputation: 8692

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)

Upvotes: 4

Related Questions