Skip to content

How to use additional flags to a 'jest-playwright --parallel' script? #2343

@MtthsB

Description

@MtthsB

Dear contributors

I have recently switched from puppeteer to playwright, but I'm struggling to implement a - what I feel should be - simple use case. I would like to avoid running a multiple and parallel cross-browser test on all my tests, and instead just focus on those test files that have changed, cf. the --o flag in jest. Furthermore, I only want to use playwright for the virtual regression tests, not for purely functional unit tests. I have created separate files for both types of tests, and would therefore discern between the two by passing a specific --testRegex flag.

I am using the following setup:
"jest": "^24.8.0",
"jest-playwright-preset": "^0.1.3",
"jest-screenshot": "^0.2.2",
"playwright": "^1.0.1"
... and I have implemented the recommended jest-playwright.config.js to enable multiple browser testing and I have set the jest setup in the package json as indicated.

As it stands, I can run the "jest-playwright --parallel --testRegex='"(.)*\.vr\.test\.js(x)"'" command and it will smoothly find the test files named ***.vr.test.jsx and test them. However, if I want to add ANYTHING to that command (such as the --o to watch only changed files, or to update a screenshot with --update), it will fail and run multiple browser tests for everything that matches the default jest testMatch regexes.

I don't know what I'm missing, but I've traced the settings as far down as I could and can only find that for some reason the testRegex is reverted to an empty array in the playwrightEnvironment instance and it is literally impossible to work with the testing framework.

I would love to contribute with a solution, but I'm afraid I got stuck debugging... Any help would be awesome.

thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions