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

testing - Playwright - No longer running setup action - Stack Overflow

programmeradmin4浏览0评论

I have a project which has this setup :

MyProject
 -- tests
    playwright.config.js
    package.json
    -- playwright
       -- setup
          auth.js
       -- specs
          example.spec.js

The setup login into the website. It's required for others tests.

Here is my playwright.config.js

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './playwright/specs',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: 'html',
  use: {
    trace: 'on-first-retry',
  },

  projects: [
    {
      name: 'setup',
      testMatch: "./playwright/setup/auth.js"
    },
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
        storageState: './playwright/.auth/user.json'
      },
      dependencies: ['setup'],
    },
    {
      name: 'firefox',
      use: {
        ...devices['Firefox'],
        storageState: './playwright/.auth/user.json'
      },
      dependencies: ['setup'],
    }
  ]
});

After the first run, it was working fine, the file .auth/user.json was generated and tests were well logged. But then, I removed the file to make it re-login, but it never run the setup again. Each time, it directly try to run tests, which leads to failure:

Error: Error reading storage state from ./playwright/.auth/user.json:
ENOENT: no such file or directory, open 'C:\Dir\To\MyProject\tests\playwright\.auth\user.json'

How can I force to run the "setup" step ?

I'm running npx playwright test from folder "tests"

发布评论

评论列表(0)

  1. 暂无评论