From e220f630623941e334358c36e056e20bb91c80bb Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 11:43:26 +0200 Subject: [PATCH 1/7] Update test to retry assertion on empty file --- integrations/postcss/index.test.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/integrations/postcss/index.test.ts b/integrations/postcss/index.test.ts index e98ed40d82bb..ec76e391f95c 100644 --- a/integrations/postcss/index.test.ts +++ b/integrations/postcss/index.test.ts @@ -1,5 +1,16 @@ import path from 'node:path' -import { candidate, css, html, IS_WINDOWS, js, json, test, ts, yaml } from '../utils' +import { + candidate, + css, + html, + IS_WINDOWS, + js, + json, + retryAssertion, + test, + ts, + yaml, +} from '../utils' test( 'production build (string)', @@ -677,12 +688,7 @@ if (!IS_WINDOWS) { message.includes('does-not-exist is not exported from package'), ) - expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(` - " - --- dist/out.css --- - - " - `) + retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) await process.onStderr((message) => message.includes('Waiting for file changes...')) @@ -718,12 +724,7 @@ if (!IS_WINDOWS) { ) await process.onStderr((message) => message.includes('Finished src/index.css')) - expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(` - " - --- dist/out.css --- - - " - `) + retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) }, ) } From e91d6bd45e303151fc9d9fb43b5449a39da8f15e Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 12:08:37 +0200 Subject: [PATCH 2/7] Try again I guess --- integrations/postcss/index.test.ts | 147 +++++++++++++---------------- 1 file changed, 66 insertions(+), 81 deletions(-) diff --git a/integrations/postcss/index.test.ts b/integrations/postcss/index.test.ts index ec76e391f95c..0039790f0d3c 100644 --- a/integrations/postcss/index.test.ts +++ b/integrations/postcss/index.test.ts @@ -1,16 +1,5 @@ import path from 'node:path' -import { - candidate, - css, - html, - IS_WINDOWS, - js, - json, - retryAssertion, - test, - ts, - yaml, -} from '../utils' +import { candidate, css, html, js, json, retryAssertion, test, ts, yaml } from '../utils' test( 'production build (string)', @@ -647,62 +636,59 @@ test( }, ) -if (!IS_WINDOWS) { - test( - 'rebuild error recovery', - { - fs: { - 'package.json': json` - { - "devDependencies": { - "postcss": "^8", - "postcss-cli": "^10", - "tailwindcss": "workspace:^", - "@tailwindcss/postcss": "workspace:^" - } - } - `, - 'postcss.config.js': js` - module.exports = { - plugins: { - '@tailwindcss/postcss': {}, - }, +test( + 'rebuild error recovery', + { + fs: { + 'package.json': json` + { + "devDependencies": { + "postcss": "^8", + "postcss-cli": "^10", + "tailwindcss": "workspace:^", + "@tailwindcss/postcss": "workspace:^" } - `, - 'src/index.html': html` + } + `, + 'postcss.config.js': js` + module.exports = { + plugins: { + '@tailwindcss/postcss': {}, + }, + } + `, + 'src/index.html': html`
`, - 'src/index.css': css` @import './tailwind.css'; `, - 'src/tailwind.css': css` - @reference 'tailwindcss/does-not-exist'; - @import 'tailwindcss/utilities'; - `, - }, + 'src/index.css': css` @import './tailwind.css'; `, + 'src/tailwind.css': css` + @reference 'tailwindcss/does-not-exist'; + @import 'tailwindcss/utilities'; + `, }, - async ({ fs, expect, spawn }) => { - let process = await spawn( - 'pnpm postcss src/index.css --output dist/out.css --watch --verbose', - ) - - await process.onStderr((message) => - message.includes('does-not-exist is not exported from package'), - ) - - retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) - - await process.onStderr((message) => message.includes('Waiting for file changes...')) - - // Fix the CSS file - await fs.write( - 'src/tailwind.css', - css` - @reference 'tailwindcss/theme'; - @import 'tailwindcss/utilities'; - `, - ) - await process.onStderr((message) => message.includes('Finished src/index.css')) - - expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(` + }, + async ({ fs, expect, spawn }) => { + let process = await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose') + + await process.onStderr((message) => + message.includes('does-not-exist is not exported from package'), + ) + + retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) + + await process.onStderr((message) => message.includes('Waiting for file changes...')) + + // Fix the CSS file + await fs.write( + 'src/tailwind.css', + css` + @reference 'tailwindcss/theme'; + @import 'tailwindcss/utilities'; + `, + ) + await process.onStderr((message) => message.includes('Finished src/index.css')) + + expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(` " --- dist/out.css --- .underline { @@ -711,20 +697,19 @@ if (!IS_WINDOWS) { " `) - // Now break the CSS file again - await fs.write( - 'src/tailwind.css', - css` - @reference 'tailwindcss/does-not-exist'; - @import 'tailwindcss/utilities'; - `, - ) - await process.onStderr((message) => - message.includes('does-not-exist is not exported from package'), - ) - await process.onStderr((message) => message.includes('Finished src/index.css')) - - retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) - }, - ) -} + // Now break the CSS file again + await fs.write( + 'src/tailwind.css', + css` + @reference 'tailwindcss/does-not-exist'; + @import 'tailwindcss/utilities'; + `, + ) + await process.onStderr((message) => + message.includes('does-not-exist is not exported from package'), + ) + await process.onStderr((message) => message.includes('Finished src/index.css')) + + retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) + }, +) From 957af156baccdcf1d80a8c57a7ae8f54309f7b37 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 14:17:39 +0200 Subject: [PATCH 3/7] Add await --- integrations/postcss/index.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/postcss/index.test.ts b/integrations/postcss/index.test.ts index 0039790f0d3c..186b3f86ce7b 100644 --- a/integrations/postcss/index.test.ts +++ b/integrations/postcss/index.test.ts @@ -674,7 +674,7 @@ test( message.includes('does-not-exist is not exported from package'), ) - retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) + await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) await process.onStderr((message) => message.includes('Waiting for file changes...')) @@ -710,6 +710,6 @@ test( ) await process.onStderr((message) => message.includes('Finished src/index.css')) - retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) + await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) }, ) From 82a7ca6ad12e89d0c0d6af1833d4445b60ea8861 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 15:13:46 +0200 Subject: [PATCH 4/7] Try again I guess From 955bdc339a4116cb24b33a33acc46b1ea9453295 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 15:35:43 +0200 Subject: [PATCH 5/7] Remove broken assertions --- integrations/postcss/index.test.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/integrations/postcss/index.test.ts b/integrations/postcss/index.test.ts index 186b3f86ce7b..bcfbb8aa79f4 100644 --- a/integrations/postcss/index.test.ts +++ b/integrations/postcss/index.test.ts @@ -1,5 +1,5 @@ import path from 'node:path' -import { candidate, css, html, js, json, retryAssertion, test, ts, yaml } from '../utils' +import { candidate, css, html, js, json, test, ts, yaml } from '../utils' test( 'production build (string)', @@ -674,8 +674,6 @@ test( message.includes('does-not-exist is not exported from package'), ) - await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) - await process.onStderr((message) => message.includes('Waiting for file changes...')) // Fix the CSS file @@ -709,7 +707,5 @@ test( message.includes('does-not-exist is not exported from package'), ) await process.onStderr((message) => message.includes('Finished src/index.css')) - - await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) }, ) From 7c30c57974db07270add29bf823b8fdb32a3cf62 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 16:21:47 +0200 Subject: [PATCH 6/7] There is no way --- integrations/postcss/index.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/integrations/postcss/index.test.ts b/integrations/postcss/index.test.ts index bcfbb8aa79f4..7a263ba92d51 100644 --- a/integrations/postcss/index.test.ts +++ b/integrations/postcss/index.test.ts @@ -1,5 +1,5 @@ import path from 'node:path' -import { candidate, css, html, js, json, test, ts, yaml } from '../utils' +import { candidate, css, html, js, json, retryAssertion, test, ts, yaml } from '../utils' test( 'production build (string)', @@ -674,6 +674,8 @@ test( message.includes('does-not-exist is not exported from package'), ) + await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) + await process.onStderr((message) => message.includes('Waiting for file changes...')) // Fix the CSS file @@ -684,7 +686,7 @@ test( @import 'tailwindcss/utilities'; `, ) - await process.onStderr((message) => message.includes('Finished src/index.css')) + await process.onStderr((message) => message.includes('Finished')) expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(` " @@ -706,6 +708,7 @@ test( await process.onStderr((message) => message.includes('does-not-exist is not exported from package'), ) - await process.onStderr((message) => message.includes('Finished src/index.css')) + + await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual('')) }, ) From ecd658080c20a8712f2b13de8a0148cd14e1176e Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 29 Apr 2025 17:10:39 +0200 Subject: [PATCH 7/7] Try again I guess