@@ -14,54 +14,50 @@ describe('astro cli', () => {
1414 } ) ;
1515
1616 // Flaky test, in CI it exceeds the timeout most of the times
17- it . skip (
18- 'astro check --watch reports errors on modified files' ,
19- {
20- timeout : 35000 ,
21- } ,
22- async ( ) => {
23- let messageResolve ;
24- const messagePromise = new Promise ( ( resolve ) => {
25- messageResolve = resolve ;
26- } ) ;
27- const oneErrorContent = 'foobar' ;
17+ it . skip ( 'astro check --watch reports errors on modified files' , {
18+ timeout : 35000 ,
19+ } , async ( ) => {
20+ let messageResolve ;
21+ const messagePromise = new Promise ( ( resolve ) => {
22+ messageResolve = resolve ;
23+ } ) ;
24+ const oneErrorContent = 'foobar' ;
2825
29- /** @type {import('./test-utils').Fixture } */
30- const fixture = await loadFixture ( {
31- root : './fixtures/astro-check-watch/' ,
32- } ) ;
33- const logs = [ ] ;
26+ /** @type {import('./test-utils').Fixture } */
27+ const fixture = await loadFixture ( {
28+ root : './fixtures/astro-check-watch/' ,
29+ } ) ;
30+ const logs = [ ] ;
3431
35- const checkServer = await fixture . check ( {
36- flags : { watch : true } ,
37- logging : {
38- level : 'info' ,
39- dest : new Writable ( {
40- objectMode : true ,
41- write ( event , _ , callback ) {
42- logs . push ( { ...event , message : stripVTControlCharacters ( event . message ) } ) ;
43- if ( event . message . includes ( '1 error' ) ) {
44- messageResolve ( logs ) ;
45- }
46- callback ( ) ;
47- } ,
48- } ) ,
49- } ,
50- } ) ;
51- await checkServer . watch ( ) ;
52- const pagePath = join ( fileURLToPath ( fixture . config . root ) , 'src/pages/index.astro' ) ;
53- const pageContent = readFileSync ( pagePath , 'utf-8' ) ;
54- await fs . writeFile ( pagePath , oneErrorContent ) ;
55- const messages = await messagePromise ;
56- await fs . writeFile ( pagePath , pageContent ) ;
57- await checkServer . stop ( ) ;
58- const diagnostics = messages . filter (
59- ( m ) => m . type === 'diagnostics' && m . message . includes ( 'Result' ) ,
60- ) ;
61- assert . equal ( diagnostics [ 0 ] . message . includes ( '0 errors' ) , true ) ;
62- assert . equal ( diagnostics [ 1 ] . message . includes ( '1 error' ) , true ) ;
63- } ,
64- ) ;
32+ const checkServer = await fixture . check ( {
33+ flags : { watch : true } ,
34+ logging : {
35+ level : 'info' ,
36+ dest : new Writable ( {
37+ objectMode : true ,
38+ write ( event , _ , callback ) {
39+ logs . push ( { ...event , message : stripVTControlCharacters ( event . message ) } ) ;
40+ if ( event . message . includes ( '1 error' ) ) {
41+ messageResolve ( logs ) ;
42+ }
43+ callback ( ) ;
44+ } ,
45+ } ) ,
46+ } ,
47+ } ) ;
48+ await checkServer . watch ( ) ;
49+ const pagePath = join ( fileURLToPath ( fixture . config . root ) , 'src/pages/index.astro' ) ;
50+ const pageContent = readFileSync ( pagePath , 'utf-8' ) ;
51+ await fs . writeFile ( pagePath , oneErrorContent ) ;
52+ const messages = await messagePromise ;
53+ await fs . writeFile ( pagePath , pageContent ) ;
54+ await checkServer . stop ( ) ;
55+ const diagnostics = messages . filter (
56+ ( m ) => m . type === 'diagnostics' && m . message . includes ( 'Result' ) ,
57+ ) ;
58+ assert . equal ( diagnostics [ 0 ] . message . includes ( '0 errors' ) , true ) ;
59+ assert . equal ( diagnostics [ 1 ] . message . includes ( '1 error' ) , true ) ;
60+ } ) ;
6561
6662 it ( 'astro --version' , async ( ) => {
6763 const pkgURL = new URL ( '../package.json' , import . meta. url ) ;
@@ -72,39 +68,31 @@ describe('astro cli', () => {
7268 assert . equal ( result . stdout . includes ( pkgVersion ) , true ) ;
7369 } ) ;
7470
75- it (
76- 'astro check no errors' ,
77- {
78- timeout : 35000 ,
79- } ,
80- async ( ) => {
81- const projectRootURL = new URL ( './fixtures/astro-check-no-errors/' , import . meta. url ) ;
82- const result = await cli (
83- 'check' ,
84- '--root' ,
85- fileURLToPath ( projectRootURL ) ,
86- '--noSync' ,
87- ) . getResult ( ) ;
71+ it ( 'astro check no errors' , {
72+ timeout : 35000 ,
73+ } , async ( ) => {
74+ const projectRootURL = new URL ( './fixtures/astro-check-no-errors/' , import . meta. url ) ;
75+ const result = await cli (
76+ 'check' ,
77+ '--root' ,
78+ fileURLToPath ( projectRootURL ) ,
79+ '--noSync' ,
80+ ) . getResult ( ) ;
8881
89- assert . equal ( result . stdout . includes ( '0 errors' ) , true ) ;
90- } ,
91- ) ;
82+ assert . equal ( result . stdout . includes ( '0 errors' ) , true ) ;
83+ } ) ;
9284
93- it (
94- 'astro check has errors' ,
95- {
96- timeout : 35000 ,
97- } ,
98- async ( ) => {
99- const projectRootURL = new URL ( './fixtures/astro-check-errors/' , import . meta. url ) ;
100- const result = await cli (
101- 'check' ,
102- '--root' ,
103- fileURLToPath ( projectRootURL ) ,
104- '--noSync' ,
105- ) . getResult ( ) ;
85+ it ( 'astro check has errors' , {
86+ timeout : 35000 ,
87+ } , async ( ) => {
88+ const projectRootURL = new URL ( './fixtures/astro-check-errors/' , import . meta. url ) ;
89+ const result = await cli (
90+ 'check' ,
91+ '--root' ,
92+ fileURLToPath ( projectRootURL ) ,
93+ '--noSync' ,
94+ ) . getResult ( ) ;
10695
107- assert . equal ( result . stdout . includes ( '1 error' ) , true ) ;
108- } ,
109- ) ;
96+ assert . equal ( result . stdout . includes ( '1 error' ) , true ) ;
97+ } ) ;
11098} ) ;
0 commit comments