Skip to content

Update test to retry assertion on empty file and don't include forward-slash in the assertion #17821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 60 additions & 75 deletions integrations/postcss/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path'
import { candidate, css, html, IS_WINDOWS, js, json, test, ts, yaml } from '../utils'
import { candidate, css, html, js, json, retryAssertion, test, ts, yaml } from '../utils'

test(
'production build (string)',
Expand Down Expand Up @@ -636,67 +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`
<div class="underline"></div>
`,
'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',
)
},
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'),
)
await process.onStderr((message) =>
message.includes('does-not-exist is not exported from package'),
)

expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
"
--- dist/out.css ---
<EMPTY>
"
`)
await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual(''))

await process.onStderr((message) => message.includes('Waiting for file changes...'))
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'))
// Fix the CSS file
await fs.write(
'src/tailwind.css',
css`
@reference 'tailwindcss/theme';
@import 'tailwindcss/utilities';
`,
)
await process.onStderr((message) => message.includes('Finished'))

expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
"
--- dist/out.css ---
.underline {
Expand All @@ -705,25 +697,18 @@ 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'))

expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
"
--- dist/out.css ---
<EMPTY>
"
`)
},
)
}
// 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 retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual(''))
},
)