132132
133133``` typescript
134134import { test , expect } from ' @playwright/test' ;
135- import { readFileSync } from ' fs' ;
135+ import { readFileSync , readdirSync } from ' fs' ;
136136import { resolve } from ' path' ;
137137
138138test .describe (' TailwindCSS v4 configuration' , () => {
@@ -145,9 +145,20 @@ test.describe('TailwindCSS v4 configuration', () => {
145145
146146 test (' primary color is generated in CSS' , () => {
147147 const cssDir = resolve (' .svelte-kit/output/client/_app/immutable/assets' );
148- const cssFiles = require (' fs' )
149- .readdirSync (cssDir )
150- .filter ((f : string ) => f .startsWith (' 0.' ) && f .endsWith (' .css' ));
148+ let cssFiles: string [] = [];
149+
150+ try {
151+ const allCssFiles = readdirSync (cssDir ).filter ((f : string ) => f .endsWith (' .css' ));
152+ cssFiles = allCssFiles .filter ((f : string ) => f .startsWith (' 0.' ));
153+
154+ // Fallback: use any CSS file if no 0.*.css files found
155+ if (cssFiles .length === 0 ) {
156+ cssFiles = allCssFiles ;
157+ }
158+ } catch (e ) {
159+ // True error: directory not found or inaccessible
160+ throw new Error (` CSS directory not found: ${cssDir } ` );
161+ }
151162
152163 expect (cssFiles .length ).toBeGreaterThan (0 );
153164
@@ -171,16 +182,17 @@ test.describe('TailwindCSS v4 configuration', () => {
171182 expect (css ).toMatch (/ \. bg-atcoder-/ );
172183 });
173184
174- test (' xs breakpoint is available ' , () => {
185+ test (' xs breakpoint media queries are generated in CSS ' , () => {
175186 const cssDir = resolve (' .svelte-kit/output/client/_app/immutable/assets' );
176187 const cssFiles = require (' fs' )
177188 .readdirSync (cssDir )
178189 .filter ((f : string ) => f .startsWith (' 0.' ) && f .endsWith (' .css' ));
179190 const cssPath = resolve (cssDir , cssFiles [0 ]);
180191 const css = readFileSync (cssPath , ' utf-8' );
181192
182- // CSS が正常に生成されているか(サイズ確認)
183- expect (css .length ).toBeGreaterThan (10000 );
193+ // xs: プレフィックス付きクラスが CSS に含まれているか確認
194+ // TailwindCSS v4 では @media クエリで xs breakpoint が定義される
195+ expect (allCss ).toMatch (/ @media\( min-width:26\. 25rem\) / );
184196 });
185197});
186198```
@@ -197,7 +209,7 @@ pnpm playwright test tests/custom-colors.spec.ts
197209
198210- ✅ primary color classes が CSS に含まれている
199211- ✅ atcoder color classes が CSS に含まれている
200- - ✅ ビルド出力が正常に生成されている
212+ - ✅ xs: プレフィックス付きクラスが CSS に含まれている(breakpoint 生成確認)
201213
202214---
203215
0 commit comments