最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Playwright execute setup database with 2 devices - Stack Overflow

programmeradmin2浏览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"]
        }
    ],```
发布评论

评论列表(0)

  1. 暂无评论