0

I have 2 devices, chromium and a tablet. I want to execute a setup db script before each device, because the execution of the test on the first device may alter the results of the second one.

So the order would be something like this:

Setup for device 1 > tests execution with device 1 > Setup for device 2 > tests execution with device 2

I've tried so many things but I don't know how to make it, I have something like this in my playwright.config.ts, but when run the tablet tests doesn't execute:

 projects: [
        //look for the global.setup.ts file, when all the dependents ended call the teardown (cleanup db)
        {
            name: 'setup chromium db',
            testMatch: /global\.setup\.ts/,
            // teardown: 'cleanup chromium db',
        },
        {
            name: 'setup tablet db',
            testMatch: /global\.setup\.ts/,
            dependencies: ["chromium"],
        },
        //look for the global.teardown.ts file and execute it to clean up the db
        {
            name: 'chromium',
            use: {...devices['Desktop Chrome']},
            dependencies: ["setup chromium db"],
        },
        {
            name: "tablet",
            use: {
                viewport: {
                    width: 700,
                    height: 1110
                },
                userAgent: 'Mozilla/5.0 (Linux; Android 10; CustomTablet) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Mobile Safari/537.36',
                deviceScaleFactor: 2,
                isMobile: true,
                hasTouch: true,
                browserName: 'chromium',
            },
            dependencies: ["setup tablet db"]
        }
    ],```
1
  • 1
    Can you add a command for how you run your tests? Just ‘npx playwright test’? Commented Mar 7 at 16:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.