File tree Expand file tree Collapse file tree
packages/integrations/cloudflare/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,8 +43,20 @@ describe('Prerendered page styles', () => {
4343 it ( 'includes Tailwind styles in prerendered page' , async ( ) => {
4444 // With cloudflare adapter, prerendered pages are in dist/client/
4545 const html = await fixture . readFile ( '/client/index.html' ) ;
46- // Check that the bg-amber-500 class has its styles included
47- assert . ok ( html . includes ( '.bg-amber-500' ) , 'Expected .bg-amber-500 class to be in the HTML' ) ;
46+ // Tailwind CSS is emitted as an external stylesheet linked from the HTML.
47+ // Verify the HTML references a stylesheet and that the stylesheet contains the expected class.
48+ assert . ok ( html . includes ( 'rel="stylesheet"' ) , 'Expected the HTML to reference a stylesheet' ) ;
49+ const cssFiles = await fixture . glob ( 'client/_astro/*.css' ) ;
50+ assert . ok ( cssFiles . length > 0 , 'Expected at least one CSS file in _astro/' ) ;
51+ let foundClass = false ;
52+ for ( const cssFile of cssFiles ) {
53+ const css = await fixture . readFile ( '/' + cssFile ) ;
54+ if ( css . includes ( '.bg-amber-500' ) ) {
55+ foundClass = true ;
56+ break ;
57+ }
58+ }
59+ assert . ok ( foundClass , 'Expected .bg-amber-500 class to be in a generated CSS file' ) ;
4860 } ) ;
4961 } ) ;
5062} ) ;
You can’t perform that action at this time.
0 commit comments