Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions packages/ui/client/composables/client/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,9 @@ export function createStaticClient(): VitestClient {

async function registerMetadata() {
const res = await fetch(window.METADATA_PATH!)
const contentType = res.headers.get('content-type')?.toLowerCase() || ''
if (
contentType.includes('application/gzip')
|| contentType.includes('application/x-gzip')
) {
const compressed = new Uint8Array(await res.arrayBuffer())
const decompressed = strFromU8(decompressSync(compressed))
metadata = parse(decompressed) as HTMLReportMetadata
}
else {
metadata = parse(await res.text()) as HTMLReportMetadata
}
const compressed = new Uint8Array(await res.arrayBuffer())
const decompressed = strFromU8(decompressSync(compressed))
metadata = parse(decompressed) as HTMLReportMetadata
const event = new Event('open')
ctx.ws.dispatchEvent(event)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/node/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default class HTMLReporter implements Reporter {
}

async writeReport(report: string): Promise<void> {
const metaFile = resolve(this.reporterDir, 'html.meta.json.gz')
const metaFile = resolve(this.reporterDir, 'html.meta.bin')

const promiseGzip = promisify(gzip)
const data = await promiseGzip(report, {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default defineConfig({
// name: 'debug-html-report',
// apply: 'serve',
// transformIndexHtml(html) {
// return html.replace('<!-- !LOAD_METADATA! -->', `<script>window.METADATA_PATH="${debugLink}/html.meta.json.gz"</script>`)
// return html.replace('<!-- !LOAD_METADATA! -->', `<script>window.METADATA_PATH="${debugLink}/html.meta.bin"</script>`)
// },
// },

Expand Down
8 changes: 4 additions & 4 deletions test/reporters/tests/html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('html reporter', async () => {

expect(stderr).toBe('')

const metaJsonGzipped = fs.readFileSync(resolve(root, `${basePath}/html.meta.json.gz`))
const metaJsonGzipped = fs.readFileSync(resolve(root, `${basePath}/html.meta.bin`))
const metaJson = zlib.gunzipSync(metaJsonGzipped).toString('utf-8')
const indexHtml = fs.readFileSync(resolve(root, `${basePath}/index.html`), { encoding: 'utf-8' })
const resultJson = parse(metaJson.replace(new RegExp(vitestRoot, 'g'), '<rootDir>'))
Expand All @@ -50,7 +50,7 @@ describe('html reporter', async () => {
expect(task.result.logs).not.toBeDefined()

expect(resultJson).toMatchSnapshot(`tests are passing`)
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.json.gz"')
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.bin"')
}, 120000)

it('resolves to "failing" status for test file "json-fail"', async () => {
Expand All @@ -68,7 +68,7 @@ describe('html reporter', async () => {

expect(stderr).toBe('')

const metaJsonGzipped = fs.readFileSync(resolve(root, `${basePath}/html.meta.json.gz`))
const metaJsonGzipped = fs.readFileSync(resolve(root, `${basePath}/html.meta.bin`))
const metaJson = zlib.gunzipSync(metaJsonGzipped).toString('utf-8')
const indexHtml = fs.readFileSync(resolve(root, `${basePath}/index.html`), { encoding: 'utf-8' })
const resultJson = parse(metaJson.replace(new RegExp(vitestRoot, 'g'), '<rootDir>'))
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('html reporter', async () => {
task.logs[0].time = 0

expect(resultJson).toMatchSnapshot(`tests are failing`)
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.json.gz"')
expect(indexHtml).toMatch('window.METADATA_PATH="html.meta.bin"')
}, 120000)
})

Expand Down
Loading