0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Playwrightのretry設定について

Posted at

retry設定とは

Playwrightではtestが失敗した際に再試行することができる。これがretryだ。

retryについてはいくつかの設定方法がある。

playwright.config.ts

playwright.config.tsには以下のような記述がある。

  /* Retry on CI only */
  retries: process.env.CI ? 2 : 0,

これは、CI環境ならば2回、違うならば0回 retryするということだ。

CI環境とは、githubActions等の環境のことだが、Playwrightはこれを感知することができるため、区別されている。

test.describe.configre()

以下の様に、configure()を用いて playwright.config.tsの設定をオーバーライドすることもできる。

test.describe('slider2', () => {
  test.describe.configure({ retries: 3 });  // このブロック内のすべてのテストに適用
  
  test('test case 1', async ({ page }) => {
    // テストコード
  });

  test('test case 2', async ({ page }) => {
    // テストコード
  });
});

retry環境下でのみ実行する処理を記述する

以下のようにretry環境下でのみ実行する処理を記述することもできる。

  test('slider2', async ({ page }, testInfo) => {
    if (testInfo.retry) {
      console.log('This test is being retried');
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?