This thread is trying to answer question "Is there a way to configure playwright to only pay attention to the .ts files?"
There shouldn’t be a need to compile to JS files for playwright tests. They can stay as TS files and run fine.
That being said to answer your question
https://playwright.dev/docs/api/class-testconfig
Using testMatch in your playwright config is what you are looking for.
Related Ask AI answer for "How do I set up Playwright to only run .ts test files?".
Sure, you can configure Playwright to only consider .ts files as test files. This is done by modifying the testConfig.testMatch
option in the playwright.config.ts
file.
By default, Playwright runs .test.(js|ts|mjs)
and .spec.(js|ts|mjs)
files. But you can change this. Say your .ts test files are in a "tests" directory and follow a "example.spec.ts" naming pattern. You can set testConfig.testMatch
to 'tests/**/*.spec.ts'
. This tells Playwright to only run .ts test files that match this pattern.
Here's how you can do this in your playwright.config.ts
file:
import { defineConfig } from '@playwright/test';
export default defineConfig({
// Other configuration options...
testConfig: {
// Other test configuration options...
// Specify the glob pattern for .ts test files
testMatch: 'tests/**/*.spec.ts',
},
});
Now, when you run tests with Playwright, it will only consider and execute the .ts test files that match the specified glob pattern.
Remember, this information is based on the context provided. If there are other ways to configure Playwright for this purpose that aren't mentioned here, I'm not aware of them.
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 [email protected].