From f3d7a3a3de475953b7a50e712df2801f78b91ed5 Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Sun, 14 Jul 2024 21:20:27 +0545 Subject: [PATCH] chore: speed up CI a bit (hopefully) (#9731) Co-authored-by: Rich Harris Co-authored-by: Tee Ming Co-authored-by: Rich Harris Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++ .../load/cache-control/bust/+page.svelte | 2 +- .../load/cache-control/bust/count/+server.js | 6 ++- .../cache-control/bust/increment/+server.js | 10 +++-- .../routes/load/cache-control/bust/state.js | 9 ----- .../load/cache-control/default/+page.svelte | 9 +++-- .../cache-control/default/count/+server.js | 6 ++- .../default/increment/+server.js | 10 +++-- .../load/cache-control/default/state.js | 9 ----- .../load/cache-control/force/+page.svelte | 2 +- .../load/cache-control/force/count/+server.js | 6 ++- .../cache-control/force/increment/+server.js | 10 +++-- .../routes/load/cache-control/force/state.js | 9 ----- .../kit/test/apps/basics/test/client.test.js | 30 ++++++++------ .../basics/test/cross-platform/client.test.js | 37 +++++++++-------- .../apps/basics/test/cross-platform/test.js | 9 +---- packages/kit/test/apps/basics/test/test.js | 2 +- packages/kit/test/apps/embed/test/test.js | 4 +- .../kit/test/github-flaky-warning-reporter.js | 15 +++++-- packages/kit/test/utils.d.ts | 11 ++--- packages/kit/test/utils.js | 40 ++++++++++++------- packages/package/.gitignore | 2 + scripts/print-flaky-test-report.js | 15 +++++++ 23 files changed, 148 insertions(+), 109 deletions(-) delete mode 100644 packages/kit/test/apps/basics/src/routes/load/cache-control/bust/state.js delete mode 100644 packages/kit/test/apps/basics/src/routes/load/cache-control/default/state.js delete mode 100644 packages/kit/test/apps/basics/src/routes/load/cache-control/force/state.js create mode 100644 scripts/print-flaky-test-report.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be8f56457373..a8e35a53dc16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,8 @@ jobs: - run: pnpm playwright install ${{ matrix.e2e-browser }} - run: pnpm run sync-all - run: pnpm test:kit + - name: Print flaky test report + run: node scripts/print-flaky-test-report.js - name: Archive test results if: failure() shell: bash @@ -115,6 +117,8 @@ jobs: - run: pnpm playwright install ${{ matrix.e2e-browser }} - run: pnpm run sync-all - run: pnpm test:cross-platform:${{ matrix.mode }} + - name: Print flaky test report + run: node scripts/print-flaky-test-report.js - name: Archive test results if: failure() shell: bash diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/+page.svelte b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/+page.svelte index da9d1efb73e6..b9080af1f26c 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/+page.svelte @@ -11,5 +11,5 @@ } -

Count is {data.count}

+

Count is {data.count}

diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/count/+server.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/count/+server.js index 999b7fd7cd0a..49c2e014b003 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/count/+server.js +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/count/+server.js @@ -1,8 +1,10 @@ import { json } from '@sveltejs/kit'; -import { count } from '../state.js'; -export function GET({ setHeaders }) { +export function GET({ setHeaders, cookies }) { setHeaders({ 'cache-control': 'public, max-age=4', age: '2' }); + + const count = +(cookies.get('cache-control-bust-count') ?? 0); + return json({ count }); } diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/increment/+server.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/increment/+server.js index 1ddf1e429013..2e30bdd1d9a4 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/increment/+server.js +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/increment/+server.js @@ -1,7 +1,11 @@ import { json } from '@sveltejs/kit'; -import { increment } from '../state.js'; -export function GET() { - increment(); +export function GET({ cookies }) { + cookies.set( + 'cache-control-bust-count', + +(cookies.get('cache-control-bust-count') ?? 0) + 1 + '', + { path: '/' } + ); + return json({}); } diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/state.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/state.js deleted file mode 100644 index ba1431d4079a..000000000000 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/bust/state.js +++ /dev/null @@ -1,9 +0,0 @@ -export let count = 0; - -export function increment() { - return count++; -} - -export function reset() { - count = 0; -} diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/+page.svelte b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/+page.svelte index 3d51fd478570..ecd93c6ab44d 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/+page.svelte @@ -4,11 +4,14 @@ /** @type {import('./$types').PageData} */ export let data; + let ticker = 0; async function update() { + ticker += 1; await fetch('/load/cache-control/default/increment'); - invalidate('/load/cache-control/default/count'); + await invalidate('/load/cache-control/default/count'); + ticker += 1; } -

Count is {data.count}

- +

Count is {data.count}

+ diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/count/+server.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/count/+server.js index 999b7fd7cd0a..8579f6fc1ca7 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/count/+server.js +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/count/+server.js @@ -1,8 +1,10 @@ import { json } from '@sveltejs/kit'; -import { count } from '../state.js'; -export function GET({ setHeaders }) { +export function GET({ setHeaders, cookies }) { setHeaders({ 'cache-control': 'public, max-age=4', age: '2' }); + + const count = +(cookies.get('cache-control-default-count') ?? 0); + return json({ count }); } diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/increment/+server.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/increment/+server.js index 1ddf1e429013..0cd89b430a60 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/increment/+server.js +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/increment/+server.js @@ -1,7 +1,11 @@ import { json } from '@sveltejs/kit'; -import { increment } from '../state.js'; -export function GET() { - increment(); +export function GET({ cookies }) { + cookies.set( + 'cache-control-default-count', + +(cookies.get('cache-control-default-count') ?? 0) + 1 + '', + { path: '/' } + ); + return json({}); } diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/state.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/default/state.js deleted file mode 100644 index ba1431d4079a..000000000000 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/default/state.js +++ /dev/null @@ -1,9 +0,0 @@ -export let count = 0; - -export function increment() { - return count++; -} - -export function reset() { - count = 0; -} diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/+page.svelte b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/+page.svelte index 1b03361eada3..f8b23481af7e 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/+page.svelte @@ -10,5 +10,5 @@ } -

Count is {data.count}

+

Count is {data.count}

diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/count/+server.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/count/+server.js index 999b7fd7cd0a..b321b0650907 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/count/+server.js +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/count/+server.js @@ -1,8 +1,10 @@ import { json } from '@sveltejs/kit'; -import { count } from '../state.js'; -export function GET({ setHeaders }) { +export function GET({ setHeaders, cookies }) { setHeaders({ 'cache-control': 'public, max-age=4', age: '2' }); + + const count = +(cookies.get('cache-control-force-count') ?? 0); + return json({ count }); } diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/increment/+server.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/increment/+server.js index 1ddf1e429013..fee0dacb14f2 100644 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/increment/+server.js +++ b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/increment/+server.js @@ -1,7 +1,11 @@ import { json } from '@sveltejs/kit'; -import { increment } from '../state.js'; -export function GET() { - increment(); +export function GET({ cookies }) { + cookies.set( + 'cache-control-force-count', + +(cookies.get('cache-control-force-count') ?? 0) + 1 + '', + { path: '/' } + ); + return json({}); } diff --git a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/state.js b/packages/kit/test/apps/basics/src/routes/load/cache-control/force/state.js deleted file mode 100644 index ba1431d4079a..000000000000 --- a/packages/kit/test/apps/basics/src/routes/load/cache-control/force/state.js +++ /dev/null @@ -1,9 +0,0 @@ -export let count = 0; - -export function increment() { - return count++; -} - -export function reset() { - count = 0; -} diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js index 2d729e903adf..21693343dd4a 100644 --- a/packages/kit/test/apps/basics/test/client.test.js +++ b/packages/kit/test/apps/basics/test/client.test.js @@ -145,35 +145,41 @@ test.describe('Load', () => { }); test('load does not call fetch if max-age allows it', async ({ page }) => { - page.addInitScript(` + await page.addInitScript(` window.now = 0; window.performance.now = () => now; `); await page.goto('/load/cache-control/default'); - await expect(page.getByText('Count is 0')).toBeVisible(); - await page.locator('button').click(); - await page.waitForLoadState('networkidle'); - await expect(page.getByText('Count is 0')).toBeVisible(); - await page.evaluate(() => (window.now = 2500)); + const button = page.locator('button'); + const p = page.locator('p.counter'); - await page.locator('button').click(); - await expect(page.getByText('Count is 2')).toBeVisible(); + await button.click(); + await expect(button).toHaveAttribute('data-ticker', '2'); + await expect(p).toHaveText('Count is 0'); + + await page.evaluate('window.now = 2500'); + + await button.click(); + await expect(button).toHaveAttribute('data-ticker', '4'); + await expect(p).toHaveText('Count is 2'); }); test('load does ignore ttl if fetch cache options says so', async ({ page }) => { await page.goto('/load/cache-control/force'); - await expect(page.getByText('Count is 0')).toBeVisible(); + const p = page.locator('p.counter'); + await expect(p).toHaveText('Count is 0'); await page.locator('button').click(); - await expect(page.getByText('Count is 1')).toBeVisible(); + await expect(p).toHaveText('Count is 1'); }); test('load busts cache if non-GET request to resource is made', async ({ page }) => { await page.goto('/load/cache-control/bust'); - await expect(page.getByText('Count is 0')).toBeVisible(); + const p = page.locator('p.counter'); + await expect(p).toHaveText('Count is 0'); await page.locator('button').click(); - await expect(page.getByText('Count is 1')).toBeVisible(); + await expect(p).toHaveText('Count is 1'); }); test('__data.json has cache-control: private, no-store', async ({ page, clicknav }) => { diff --git a/packages/kit/test/apps/basics/test/cross-platform/client.test.js b/packages/kit/test/apps/basics/test/cross-platform/client.test.js index dfa97ce7f3be..5b3d1fa953f5 100644 --- a/packages/kit/test/apps/basics/test/cross-platform/client.test.js +++ b/packages/kit/test/apps/basics/test/cross-platform/client.test.js @@ -76,6 +76,7 @@ test.describe('a11y', () => { ).toBe(1); await clicknav('[href="/selection/b"]'); + expect( await page.evaluate(() => { const selection = getSelection(); @@ -98,7 +99,7 @@ test.describe('a11y', () => { }); test('autofocus from previous page is ignored', async ({ page, clicknav }) => { - page.addInitScript(` + await page.addInitScript(` window.active = null; window.addEventListener('focusin', () => window.active = document.activeElement); `); @@ -106,8 +107,13 @@ test.describe('a11y', () => { await page.goto('/accessibility/autofocus/a'); await clicknav('[href="/"]'); - expect(await page.evaluate(() => (window.active || {}).nodeName)).toBe('BODY'); - expect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY'); + expect( + await page.evaluate( + // @ts-expect-error + () => window.active?.nodeName + ) + ).toBe('BODY'); + expect(await page.evaluate(() => document.activeElement?.nodeName)).toBe('BODY'); }); }); @@ -319,20 +325,18 @@ test.describe('Scrolling', () => { expect(await page.evaluate(() => scrollY)).toBe(0); }); - test('scroll is restored after hitting the back button', async ({ baseURL, clicknav, page }) => { + test('scroll is restored after hitting the back button', async ({ clicknav, page }) => { await page.goto('/anchor'); await page.locator('#scroll-anchor').click(); const originalScrollY = /** @type {number} */ (await page.evaluate(() => scrollY)); await clicknav('#routing-page'); await page.goBack(); - await page.waitForLoadState('networkidle'); - expect(page.url()).toBe(baseURL + '/anchor#last-anchor-2'); + + await expect(page).toHaveURL('/anchor#last-anchor-2'); expect(await page.evaluate(() => scrollY)).toEqual(originalScrollY); await page.goBack(); - await page.waitForLoadState('networkidle'); - - expect(page.url()).toBe(baseURL + '/anchor'); + await expect(page).toHaveURL('/anchor'); expect(await page.evaluate(() => scrollY)).toEqual(0); }); @@ -587,18 +591,15 @@ test.describe('Prefetching', () => { expect(requests.filter((req) => req.endsWith('.js')).length).toBeGreaterThan(0); } - expect(requests.includes(`${baseURL}/routing/preloading/preloaded.json`)).toBe(true); + expect(requests).toContain(`${baseURL}/routing/preloading/preloaded.json`); requests = []; await app.goto('/routing/preloading/preloaded'); expect(requests).toEqual([]); - try { - await app.preloadData('https://example.com'); - throw new Error('Error was not thrown'); - } catch (/** @type {any} */ e) { - expect(e.message).toMatch('Attempted to preload a URL that does not belong to this app'); - } + await expect(app.preloadData('https://example.com')).rejects.toThrowError( + 'Attempted to preload a URL that does not belong to this app' + ); }); test('chooses correct route when hash route is preloaded but regular route is clicked', async ({ @@ -693,8 +694,9 @@ test.describe('Routing', () => { await page.locator('[href="#hash-target"]').click(); await clicknav('[href="/routing/hashes/b"]'); + await expect(page.locator('h1')).toHaveText('b'); await page.goBack(); - expect(await page.textContent('h1')).toBe('a'); + await expect(page.locator('h1')).toHaveText('a'); }); test('replaces state if the data-sveltekit-replacestate router option is specified for the hash link', async ({ @@ -746,6 +748,7 @@ test.describe('Routing', () => { test('responds to
submission without reload', async ({ page }) => { await page.goto('/routing/form-get'); + expect(await page.textContent('h1')).toBe('...'); expect(await page.textContent('h2')).toBe('enter'); expect(await page.textContent('h3')).toBe('...'); diff --git a/packages/kit/test/apps/basics/test/cross-platform/test.js b/packages/kit/test/apps/basics/test/cross-platform/test.js index 4d20a229fb1d..f8616f5ec9ed 100644 --- a/packages/kit/test/apps/basics/test/cross-platform/test.js +++ b/packages/kit/test/apps/basics/test/cross-platform/test.js @@ -747,7 +747,6 @@ test.describe('Routing', () => { await clicknav('[href="/routing/a"]'); await page.goBack(); - await page.waitForLoadState('networkidle'); expect(await page.textContent('h1')).toBe('Great success!'); }); @@ -755,12 +754,8 @@ test.describe('Routing', () => { await page.goto('/routing/hashes/target#p2'); await page.keyboard.press(browserName === 'webkit' ? 'Alt+Tab' : 'Tab'); - await page.waitForTimeout(50); // give browser a bit of time to complete the native behavior of the key press - expect( - await page.evaluate( - () => document.activeElement?.textContent || 'ERROR: document.activeElement not set' - ) - ).toBe('next focus element'); + + await page.waitForSelector('button:focus'); }); test('focus works when navigating to a hash on the same page', async ({ page, browserName }) => { diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js index fde55a5c3eb0..06da6474743a 100644 --- a/packages/kit/test/apps/basics/test/test.js +++ b/packages/kit/test/apps/basics/test/test.js @@ -548,7 +548,7 @@ test.describe('Load', () => { }) => { if (javaScriptEnabled) { await page.goto('/prerendering/prerendered-endpoint'); - await page.click('a', { noWaitAfter: true }); + await page.click('a'); } else { await page.goto('/prerendering/prerendered-endpoint/from-handle-hook'); } diff --git a/packages/kit/test/apps/embed/test/test.js b/packages/kit/test/apps/embed/test/test.js index 04efbbc66525..c697a71a8f63 100644 --- a/packages/kit/test/apps/embed/test/test.js +++ b/packages/kit/test/apps/embed/test/test.js @@ -10,8 +10,8 @@ test.describe('embed', () => { await page.goto('/embed'); if (javaScriptEnabled) { - expect(await page.textContent('[data-testid="a"]')).toBe('a (browser)'); - expect(await page.textContent('[data-testid="b"]')).toBe('b (browser)'); + await expect(page.getByTestId('a')).toHaveText('a (browser)'); + await expect(page.getByTestId('b')).toHaveText('b (browser)'); } else { expect(await page.textContent('[data-testid="a"]')).toBe('a (server)'); expect(await page.textContent('[data-testid="b"]')).toBe('b (server)'); diff --git a/packages/kit/test/github-flaky-warning-reporter.js b/packages/kit/test/github-flaky-warning-reporter.js index 59eb5e5a4261..9e268fcd84c7 100644 --- a/packages/kit/test/github-flaky-warning-reporter.js +++ b/packages/kit/test/github-flaky-warning-reporter.js @@ -1,3 +1,5 @@ +import { appendFileSync } from 'node:fs'; + /** * @class * @implements {import('@playwright/test/reporter').Reporter} @@ -24,12 +26,17 @@ export default class GithubFlakyWarningReporter { } onEnd() { - this._flaky.forEach(({ file, line, title, message }) => { - console.log(`::warning file=${file},line=${line},title=${title}::${message}`); - }); + const output = this._flaky + .map( + ({ file, line, title, message }) => + `::warning file=${file},line=${line},title=${title}::${message}\n` + ) + .join(''); + + appendFileSync(new URL('../../../_tmp_flaky_test_output.txt', import.meta.url), output); } printsToStdio() { - return true; + return false; } } diff --git a/packages/kit/test/utils.d.ts b/packages/kit/test/utils.d.ts index 6ba3c0b8d89f..2477beb87ae0 100644 --- a/packages/kit/test/utils.d.ts +++ b/packages/kit/test/utils.d.ts @@ -4,7 +4,8 @@ import { PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, - TestType + TestType, + Page } from '@playwright/test'; import { IncomingMessage, ServerResponse } from 'http'; import { Plugin } from 'vite'; @@ -20,7 +21,7 @@ export const test: TestType< preloadCode(...urls: string[]): Promise; preloadData(url: string): Promise; }; - clicknav(selector: string, options?: { timeout?: number }): Promise; + clicknav(selector: string, options?: Parameters[0]): Promise; in_view(selector: string): Promise; get_computed_style(selector: string, prop: string): Promise; /** @@ -30,11 +31,11 @@ export const test: TestType< start_server( handler: (req: IncomingMessage, res: ServerResponse) => void ): Promise<{ port: number }>; - page: PlaywrightTestArgs['page'] & { + page: Page & { goto: ( url: string, - opts?: Parameters[1] & { wait_for_started?: boolean } - ) => ReturnType; + opts?: Parameters[1] & { wait_for_started?: boolean } + ) => ReturnType; }; }, PlaywrightWorkerArgs & PlaywrightWorkerOptions diff --git a/packages/kit/test/utils.js b/packages/kit/test/utils.js index 630ed1c061a8..98c72bfe76f5 100644 --- a/packages/kit/test/utils.js +++ b/packages/kit/test/utils.js @@ -52,7 +52,7 @@ export const test = base.extend({ }); }, - clicknav: ({ page, javaScriptEnabled }, use) => { + clicknav: async ({ page, javaScriptEnabled }, use) => { /** * @param {string} selector * @param {{ timeout: number }} options @@ -66,10 +66,10 @@ export const test = base.extend({ } } - use(clicknav); + await use(clicknav); }, - in_view: ({ page }, use) => { + in_view: async ({ page }, use) => { /** @param {string} selector */ async function in_view(selector) { const box = await page.locator(selector).boundingBox(); @@ -77,7 +77,7 @@ export const test = base.extend({ return box && view && box.y < view.height && box.y + box.height > 0; } - use(in_view); + await use(in_view); }, get_computed_style: async ({ page }, use) => { @@ -101,25 +101,37 @@ export const test = base.extend({ const page_navigation_functions = ['goto', 'goBack', 'reload']; page_navigation_functions.forEach((fn) => { // @ts-expect-error - const page_fn = page[fn]; - if (!page_fn) { + const original_page_fn = page[fn]; + if (!original_page_fn) { throw new Error(`function does not exist on page: ${fn}`); } + // @ts-expect-error - page[fn] = async function (...args) { - const res = await page_fn.call(page, ...args); - if (javaScriptEnabled && args[1]?.wait_for_started !== false) { - await page.waitForSelector('body.started', { timeout: 15000 }); + async function modified_fn(...args) { + try { + const res = await original_page_fn.apply(page, args); + if (javaScriptEnabled && args[1]?.wait_for_started !== false) { + await page.waitForSelector('body.started', { timeout: 15000 }); + } + return res; + } catch (e) { + // Exclude this function from the stack trace so that it points to the failing test + // instead of this file. + // @ts-expect-error + Error.captureStackTrace(e, modified_fn); + throw e; } - return res; - }; + } + + // @ts-expect-error + page[fn] = modified_fn; }); await use(page); }, // eslint-disable-next-line no-empty-pattern - read_errors: ({}, use) => { + read_errors: async ({}, use) => { /** @param {string} path */ function read_errors(path) { const errors = @@ -128,7 +140,7 @@ export const test = base.extend({ return errors[path]; } - use(read_errors); + await use(read_errors); }, // eslint-disable-next-line no-empty-pattern diff --git a/packages/package/.gitignore b/packages/package/.gitignore index 7e2441dc2bf9..d670fa10a834 100644 --- a/packages/package/.gitignore +++ b/packages/package/.gitignore @@ -5,6 +5,8 @@ !/test/node_modules/ /test/apps/basics/test/errors.json .custom-out-dir/ +/test/watch/src/lib/* +!/test/watch/src/lib/index.js # these are already ignored by the top level .gitignore # repeating them here as a faux prettier ignore diff --git a/scripts/print-flaky-test-report.js b/scripts/print-flaky-test-report.js new file mode 100644 index 000000000000..d37e73ae978b --- /dev/null +++ b/scripts/print-flaky-test-report.js @@ -0,0 +1,15 @@ +// pnpm captures stdout and prefixes it with the package name which breaks the annotations +// so save it in a file and print it out at the end +// ideally we'd just use cat, but that doesn't work on Windows hence this script + +import { existsSync, createReadStream, unlinkSync } from 'node:fs'; +const filename = '_tmp_flaky_test_output.txt'; + +if (existsSync(filename)) { + createReadStream(filename) + .on('end', () => { + process.stdout.write('\n'); + unlinkSync(filename); + }) + .pipe(process.stdout); +}