Rayrun
← Back to Discord Forum

Jest tests clashing with Playwright tests

I'm adding playwright to my typescript/next.js app which already has jest/react-testing-library tests set up.

For now, I just want to add new Playwright e2e tests separately. But when I run npm run test as usual for my jest tests it fails because it tries running the Playwright tests which aren't fully compatible. I feel like I've tried all the options to exclude the playwright files from jest but it never picks them up.

Any suggestions?

This thread is trying to answer question "How can I prevent Jest tests from running Playwright tests in a typescript/next.js app?"

7 replies
deadbeef01

This will happen if we place both jest and playwright config files in root. You need to create a separate directory for playwright tests and place playwright config file inside it

ok thanks, I'll try that!

I could get playwrihght tests working by specifying the location of config file when running npx playwright test

But still can't get my jest tests to ignore playwright

We are having this problem only recently. When we added playwright we put the config at the root of our monorepo and just added all our tests into an e2e-tests folder. Then adding "e2e-tests" to our testPathIgnorePatterns setting in Jest made sure they never ran. In recent weeks Jest is now attemping to run all our playwright tests and we haven't changed any configuration.

Figured out my problem. Was rather stupid. We were missing a jest.config.js at the base of our project because we have renamed it as a baseline file. This meant VS Code didn't see a custom jest config so it reverted to the defaults.

I find it best to use "spec.js/ts" with jest and "test.js/ts" with PW.

Related Discord Threads

TwitterGitHubLinkedIn
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 [email protected].