1+ import assert from 'node:assert' ;
12import { writeFile } from 'node:fs/promises' ;
23import { platform } from 'node:process' ;
3- import { describe , expect , test , vi } from 'vitest' ;
4+ import { describe , test , vi } from 'vitest' ;
45import { runCMKInWatchMode } from './runner.js' ;
56import { fakeParsedArgs } from './test/faker.js' ;
67import { createIFF } from './test/fixture.js' ;
@@ -35,14 +36,16 @@ describe('runCMKInWatchMode', () => {
3536 await sleep ( 100 ) ;
3637 }
3738
39+ globalThis . changeCount = 0 ;
40+
3841 // Error when changing a file
3942 console . log ( 'update a.module.css' ) ;
4043 vi . spyOn ( watcher . project , 'updateFile' ) . mockImplementationOnce ( ( ) => {
4144 throw new Error ( 'test error' ) ;
4245 } ) ;
4346 await writeFile ( iff . join ( 'src/a.module.css' ) , '.a_1 { color: blue; }' ) ;
4447 await vi . waitFor ( ( ) => {
45- expect ( loggerSpy . logError ) . toHaveBeenCalledTimes ( 1 ) ;
48+ assert ( globalThis . changeCount === 1 , `Expected changeCount to be 1, but got ${ globalThis . changeCount } ` ) ;
4649 } ) ;
4750
4851 // Error when emitting files
@@ -52,6 +55,6 @@ describe('runCMKInWatchMode', () => {
5255 console . log ( 'update a.module.css' ) ;
5356 await writeFile ( iff . join ( 'src/a.module.css' ) , '.a_1 { color: yellow; }' ) ;
5457 await waitForWatcherEmitAndReportDiagnostics ( ) ;
55- expect ( loggerSpy . logError ) . toHaveBeenCalledTimes ( 2 ) ;
58+ assert ( globalThis . changeCount === 2 , `Expected changeCount to be 2, but got ${ globalThis . changeCount } ` ) ;
5659 } ) ;
5760} ) ;
0 commit comments