Skip to content

Commit d3846a4

Browse files
Update test to retry assertion on empty file and don't include forward-slash in the assertion (#17821)
To fix the CI issues we have, it turns out there are two issues: 1. The file-read was not retried, making it possible for all platforms (but mostly Windows because it's the slowest) to sometimes not have the file created yet before making the assertion. 2. A forward-slash in the assertion message path would always be a backslash when run on Windows, thus the Windows test would never pass. ## Test plan - [ci-all] and have the test pass two times.
1 parent 9fec4ef commit d3846a4

File tree

1 file changed

+60
-75
lines changed

1 file changed

+60
-75
lines changed

integrations/postcss/index.test.ts

+60-75
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path'
2-
import { candidate, css, html, IS_WINDOWS, js, json, test, ts, yaml } from '../utils'
2+
import { candidate, css, html, js, json, retryAssertion, test, ts, yaml } from '../utils'
33

44
test(
55
'production build (string)',
@@ -636,67 +636,59 @@ test(
636636
},
637637
)
638638

639-
if (!IS_WINDOWS) {
640-
test(
641-
'rebuild error recovery',
642-
{
643-
fs: {
644-
'package.json': json`
645-
{
646-
"devDependencies": {
647-
"postcss": "^8",
648-
"postcss-cli": "^10",
649-
"tailwindcss": "workspace:^",
650-
"@tailwindcss/postcss": "workspace:^"
651-
}
652-
}
653-
`,
654-
'postcss.config.js': js`
655-
module.exports = {
656-
plugins: {
657-
'@tailwindcss/postcss': {},
658-
},
639+
test(
640+
'rebuild error recovery',
641+
{
642+
fs: {
643+
'package.json': json`
644+
{
645+
"devDependencies": {
646+
"postcss": "^8",
647+
"postcss-cli": "^10",
648+
"tailwindcss": "workspace:^",
649+
"@tailwindcss/postcss": "workspace:^"
659650
}
660-
`,
661-
'src/index.html': html`
651+
}
652+
`,
653+
'postcss.config.js': js`
654+
module.exports = {
655+
plugins: {
656+
'@tailwindcss/postcss': {},
657+
},
658+
}
659+
`,
660+
'src/index.html': html`
662661
<div class="underline"></div>
663662
`,
664-
'src/index.css': css` @import './tailwind.css'; `,
665-
'src/tailwind.css': css`
666-
@reference 'tailwindcss/does-not-exist';
667-
@import 'tailwindcss/utilities';
668-
`,
669-
},
663+
'src/index.css': css` @import './tailwind.css'; `,
664+
'src/tailwind.css': css`
665+
@reference 'tailwindcss/does-not-exist';
666+
@import 'tailwindcss/utilities';
667+
`,
670668
},
671-
async ({ fs, expect, spawn }) => {
672-
let process = await spawn(
673-
'pnpm postcss src/index.css --output dist/out.css --watch --verbose',
674-
)
669+
},
670+
async ({ fs, expect, spawn }) => {
671+
let process = await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose')
675672

676-
await process.onStderr((message) =>
677-
message.includes('does-not-exist is not exported from package'),
678-
)
673+
await process.onStderr((message) =>
674+
message.includes('does-not-exist is not exported from package'),
675+
)
679676

680-
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
681-
"
682-
--- dist/out.css ---
683-
<EMPTY>
684-
"
685-
`)
677+
await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual(''))
686678

687-
await process.onStderr((message) => message.includes('Waiting for file changes...'))
679+
await process.onStderr((message) => message.includes('Waiting for file changes...'))
688680

689-
// Fix the CSS file
690-
await fs.write(
691-
'src/tailwind.css',
692-
css`
693-
@reference 'tailwindcss/theme';
694-
@import 'tailwindcss/utilities';
695-
`,
696-
)
697-
await process.onStderr((message) => message.includes('Finished src/index.css'))
681+
// Fix the CSS file
682+
await fs.write(
683+
'src/tailwind.css',
684+
css`
685+
@reference 'tailwindcss/theme';
686+
@import 'tailwindcss/utilities';
687+
`,
688+
)
689+
await process.onStderr((message) => message.includes('Finished'))
698690

699-
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
691+
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
700692
"
701693
--- dist/out.css ---
702694
.underline {
@@ -705,25 +697,18 @@ if (!IS_WINDOWS) {
705697
"
706698
`)
707699

708-
// Now break the CSS file again
709-
await fs.write(
710-
'src/tailwind.css',
711-
css`
712-
@reference 'tailwindcss/does-not-exist';
713-
@import 'tailwindcss/utilities';
714-
`,
715-
)
716-
await process.onStderr((message) =>
717-
message.includes('does-not-exist is not exported from package'),
718-
)
719-
await process.onStderr((message) => message.includes('Finished src/index.css'))
720-
721-
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
722-
"
723-
--- dist/out.css ---
724-
<EMPTY>
725-
"
726-
`)
727-
},
728-
)
729-
}
700+
// Now break the CSS file again
701+
await fs.write(
702+
'src/tailwind.css',
703+
css`
704+
@reference 'tailwindcss/does-not-exist';
705+
@import 'tailwindcss/utilities';
706+
`,
707+
)
708+
await process.onStderr((message) =>
709+
message.includes('does-not-exist is not exported from package'),
710+
)
711+
712+
await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual(''))
713+
},
714+
)

0 commit comments

Comments
 (0)