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.


Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

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.