Skip to content

Commit 242cb32

Browse files
authoredMar 4, 2025··
chore: reduce CI e2e flake (#8825)
1 parent 50a65ba commit 242cb32

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed
 

‎packages/sanity/playwright-ct.config.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import path from 'node:path'
22

33
import {defineConfig, devices} from '@playwright/experimental-ct-react'
4+
import aliases from '@repo/dev-aliases'
45

56
// Paths
67
const TESTS_PATH = path.join(__dirname, 'playwright-ct', 'tests')
78
const HTML_REPORT_PATH = path.join(__dirname, 'playwright-ct', 'report')
89
const ARTIFACT_OUTPUT_PATH = path.join(__dirname, 'playwright-ct', 'results')
910
const isCI = !!process.env.CI
11+
const monorepoPath = path.resolve(__dirname, '..', '..')
1012

1113
/**
1214
* See https://playwright.dev/docs/test-configuration.
@@ -19,11 +21,11 @@ export default defineConfig({
1921
/* Run tests in files in parallel */
2022
fullyParallel: true,
2123
/* Fail the build on CI if you accidentally left test.only in the source code. */
22-
forbidOnly: !!process.env.CI,
23-
/* Retry on CI only */
24-
retries: process.env.CI ? 6 : 0,
24+
forbidOnly: isCI,
25+
/* Flaky tests require us to allow up to 6 retries */
26+
retries: 6,
2527
/* Opt out of parallel tests on CI. */
26-
workers: process.env.CI ? 1 : undefined,
28+
workers: isCI ? 1 : undefined,
2729
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2830
reporter: isCI
2931
? [['list'], ['blob']]
@@ -55,20 +57,20 @@ export default defineConfig({
5557
/* Port to use for Playwright component endpoint. */
5658
ctPort: 3100,
5759
/* Configure Playwright vite config */
58-
/*
5960
ctViteConfig: {
6061
resolve: {
61-
alias: {
62-
'@sanity/util/content': path.join(
63-
__dirname,
64-
'./packages/@sanity/util/src/content/index.ts'
65-
),
66-
},
62+
alias: Object.fromEntries(
63+
Object.entries(aliases).map(([pkgName, pkgPath]) => {
64+
return [pkgName, path.resolve(monorepoPath, path.join('packages', pkgPath))]
65+
}),
66+
),
67+
dedupe: ['@sanity/ui', 'styled-components'],
6768
},
6869
},
69-
*/
7070
/* Where to find playwright-ct template files */
7171
ctTemplateDir: './playwright-ct/template',
72+
/* Don't wait for animations */
73+
contextOptions: {reducedMotion: 'reduce'},
7274
},
7375

7476
/* Configure projects for major browsers */
@@ -79,6 +81,7 @@ export default defineConfig({
7981
...devices['Desktop Chrome'],
8082
permissions: ['clipboard-read', 'clipboard-write'],
8183
contextOptions: {
84+
reducedMotion: 'reduce',
8285
// chromium-specific permissions
8386
permissions: ['clipboard-read', 'clipboard-write'],
8487
},

‎packages/sanity/playwright-ct/tests/formBuilder/inputs/PortableText/ObjectBlock.spec.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ test.describe('Portable Text Input', () => {
4949
await page.keyboard.press('Tab')
5050
await expect(page.getByTestId('remove-inline-object-button')).toBeFocused()
5151
await page.keyboard.press('Escape')
52-
await expect(page.getByTestId('edit-inline-object-button')).toBeVisible()
5352
await expect($pte).toBeFocused()
54-
await page.keyboard.press('Escape')
5553
// Assertion: escape closes the toolbar popover
5654
await expect(page.getByTestId('inline-object-toolbar-popover')).not.toBeVisible()
5755
})

‎playwright.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ const playwrightConfig = createPlaywrightConfig({
5959

6060
return {
6161
...config,
62-
retries: process.env.CI ? 4 : 0,
62+
retries: 4,
6363
reporter: excludeGithub(config.reporter),
6464
use: {
6565
...config.use,
6666
baseURL: 'http://localhost:3339',
6767
headless: HEADLESS,
68+
contextOptions: {reducedMotion: 'reduce'},
6869
},
6970
projects,
7071
webServer: {

0 commit comments

Comments
 (0)
Please sign in to comment.