1
1
import fs from 'fs'
2
+ import zlib from 'zlib'
2
3
import { resolve } from 'pathe'
3
4
import { execa } from 'execa'
4
5
import { describe , expect , it } from 'vitest'
@@ -21,7 +22,8 @@ describe.skipIf(skip)('html reporter', async () => {
21
22
} ,
22
23
stdio : 'inherit' ,
23
24
} ) . catch ( e => e )
24
- const metaJson = fs . readFileSync ( resolve ( root , `${ basePath } /html.meta.json` ) , { encoding : 'utf-8' } )
25
+ const metaJsonGzipeed = fs . readFileSync ( resolve ( root , `${ basePath } /html.meta.json.gz` ) )
26
+ const metaJson = zlib . gunzipSync ( metaJsonGzipeed ) . toString ( 'utf-8' )
25
27
const indexHtml = fs . readFileSync ( resolve ( root , `${ basePath } /index.html` ) , { encoding : 'utf-8' } )
26
28
const resultJson = parse ( metaJson . replace ( new RegExp ( vitestRoot , 'g' ) , '<rootDir>' ) )
27
29
resultJson . config = { } // doesn't matter for a test
@@ -38,7 +40,7 @@ describe.skipIf(skip)('html reporter', async () => {
38
40
expect ( task . result . error ) . not . toBeDefined ( )
39
41
expect ( task . result . logs ) . not . toBeDefined ( )
40
42
expect ( resultJson ) . toMatchSnapshot ( `tests are ${ expected } ` )
41
- expect ( indexHtml ) . toMatch ( 'window.METADATA_PATH="html.meta.json"' )
43
+ expect ( indexHtml ) . toMatch ( 'window.METADATA_PATH="html.meta.json.gz "' )
42
44
} , 120000 )
43
45
44
46
it ( 'resolves to "failing" status for test file "json-fail"' , async ( ) => {
@@ -52,7 +54,8 @@ describe.skipIf(skip)('html reporter', async () => {
52
54
} ,
53
55
stdio : 'inherit' ,
54
56
} ) . catch ( e => e )
55
- const metaJson = fs . readFileSync ( resolve ( root , `${ basePath } /html.meta.json` ) , { encoding : 'utf-8' } )
57
+ const metaJsonGzipped = fs . readFileSync ( resolve ( root , `${ basePath } /html.meta.json.gz` ) )
58
+ const metaJson = zlib . gunzipSync ( metaJsonGzipped ) . toString ( 'utf-8' )
56
59
const indexHtml = fs . readFileSync ( resolve ( root , `${ basePath } /index.html` ) , { encoding : 'utf-8' } )
57
60
const resultJson = parse ( metaJson . replace ( new RegExp ( vitestRoot , 'g' ) , '<rootDir>' ) )
58
61
resultJson . config = { } // doesn't matter for a test
@@ -77,6 +80,6 @@ describe.skipIf(skip)('html reporter', async () => {
77
80
task . logs [ 0 ] . taskId = 0
78
81
task . logs [ 0 ] . time = 0
79
82
expect ( resultJson ) . toMatchSnapshot ( `tests are ${ expected } ` )
80
- expect ( indexHtml ) . toMatch ( 'window.METADATA_PATH="html.meta.json"' )
83
+ expect ( indexHtml ) . toMatch ( 'window.METADATA_PATH="html.meta.json.gz "' )
81
84
} , 120000 )
82
85
} )
0 commit comments