Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: No tests found #30768

Closed
srikanthathikari opened this issue May 13, 2024 · 4 comments
Closed

Error: No tests found #30768

srikanthathikari opened this issue May 13, 2024 · 4 comments

Comments

@srikanthathikari
Copy link

srikanthathikari commented May 13, 2024

Version

1.44.0

Steps to reproduce

"I attempted to run Playwright tests using the npx playwright test command, and my tests executed successfully. However, after moving the playwright.config.ts file to a folder structured as conf/playwright.config.ts, I consistently received a 'no test found' error."
Below is the code that is causing the problem.

"scripts": {
"smoke": "npx playwright test -c conf/playwright.config.ts",

Expected behavior

I expect the tests to run, like how they if the config file is in the root of the project

Actual behavior

Error : No tests found

Additional context

No response

Environment

Mac Book Pro Sonoma
@mxschmitt
Copy link
Member

You need to adjust testDir in such kind of scenarios:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: '../tests',
});

@srikanthathikari
Copy link
Author

I am using testMatch: ['/specs/smoke/tests/*.spec.ts'], which works fine when the playwright.config.ts is at the root level.

@mxschmitt
Copy link
Member

mxschmitt commented May 14, 2024

Yes, this is because testDir is by default the directory where the playwright.config file is located. In your case you would have to change it to e.g.

import path from 'path'
import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: path.join(__dirname, '..'),
});

@sathikari
Copy link

My issue has been resolved with the provided solution. Thank you. This can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants