Skip to content

Commit 6d2bf5b

Browse files
committed
Update test
1 parent 2e9a28b commit 6d2bf5b

File tree

1 file changed

+56
-8
lines changed

1 file changed

+56
-8
lines changed

integrations/postcss/index.test.ts

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path'
2-
import { candidate, css, html, js, json, retryAssertion, test, ts, yaml } from '../utils'
2+
import { candidate, css, html, js, json, test, ts, yaml } from '../utils'
33

44
test(
55
'production build (string)',
@@ -662,35 +662,72 @@ test(
662662
`,
663663
'src/index.css': css` @import './tailwind.css'; `,
664664
'src/tailwind.css': css`
665-
@reference 'tailwindcss/does-not-exist';
665+
@reference 'tailwindcss/theme';
666666
@import 'tailwindcss/utilities';
667667
`,
668668
},
669669
},
670670
async ({ fs, expect, spawn }) => {
671+
// 1. Start the watcher
672+
//
673+
// It must have valid CSS for the initial build
671674
let process = await spawn('pnpm postcss src/index.css --output dist/out.css --watch --verbose')
672675

676+
await process.onStderr((message) => message.includes('Waiting for file changes...'))
677+
678+
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
679+
"
680+
--- dist/out.css ---
681+
.underline {
682+
text-decoration-line: underline;
683+
}
684+
"
685+
`)
686+
687+
// 2. Cause an error
688+
await fs.write(
689+
'src/tailwind.css',
690+
css`
691+
@reference 'tailwindcss/does-not-exist';
692+
@import 'tailwindcss/utilities';
693+
`,
694+
)
695+
696+
// 2.5 Write to a content file
697+
await fs.write('src/index.html', html`
698+
<div class="flex underline"></div>
699+
`)
700+
673701
await process.onStderr((message) =>
674702
message.includes('does-not-exist is not exported from package'),
675703
)
676704

677-
await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual(''))
678-
679-
await process.onStderr((message) => message.includes('Waiting for file changes...'))
705+
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
706+
"
707+
--- dist/out.css ---
708+
.underline {
709+
text-decoration-line: underline;
710+
}
711+
"
712+
`)
680713

681-
// Fix the CSS file
714+
// 3. Fix the CSS file
682715
await fs.write(
683716
'src/tailwind.css',
684717
css`
685718
@reference 'tailwindcss/theme';
686719
@import 'tailwindcss/utilities';
687720
`,
688721
)
689-
await process.onStderr((message) => message.includes('Finished'))
722+
723+
await process.onStderr((message) => message.includes('Waiting for file changes...'))
690724

691725
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
692726
"
693727
--- dist/out.css ---
728+
.flex {
729+
display: flex;
730+
}
694731
.underline {
695732
text-decoration-line: underline;
696733
}
@@ -705,11 +742,22 @@ test(
705742
@import 'tailwindcss/utilities';
706743
`,
707744
)
745+
708746
await process.onStderr((message) =>
709747
message.includes('does-not-exist is not exported from package'),
710748
)
711749

712-
await retryAssertion(async () => expect(await fs.read('dist/out.css')).toEqual(''))
750+
expect(await fs.dumpFiles('dist/*.css')).toMatchInlineSnapshot(`
751+
"
752+
--- dist/out.css ---
753+
.flex {
754+
display: flex;
755+
}
756+
.underline {
757+
text-decoration-line: underline;
758+
}
759+
"
760+
`)
713761
},
714762
)
715763

0 commit comments

Comments
 (0)