Skip to content

Commit

Permalink
chore: revert test file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 15, 2022
1 parent 1a429ed commit 1d15efa
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions test/reporters/tests/reporters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, promises as fs } from 'fs'
import { existsSync, readFileSync, rmSync, rmdirSync } from 'fs'
import { afterEach, expect, test, vi } from 'vitest'
import { normalize, resolve } from 'pathe'
import { JsonReporter } from '../../../packages/vitest/src/node/reporters/json'
Expand Down Expand Up @@ -97,10 +97,10 @@ test('JUnit reporter with outputFile', async () => {
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(outputFile, { recursive: true, force: true })
rmSync(outputFile)
})

test('JUnit reporter with outputFile object', async () => {
Expand All @@ -125,10 +125,10 @@ test('JUnit reporter with outputFile object', async () => {
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(outputFile, { recursive: true, force: true })
rmSync(outputFile)
})

test('JUnit reporter with outputFile in non-existing directory', async () => {
Expand All @@ -152,11 +152,10 @@ test('JUnit reporter with outputFile in non-existing directory', async () => {
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(rootDirectory, { recursive: true, force: true })
.catch()
rmdirSync(rootDirectory, { recursive: true })
})

test('JUnit reporter with outputFile object in non-existing directory', async () => {
Expand All @@ -182,11 +181,10 @@ test('JUnit reporter with outputFile object in non-existing directory', async ()
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(rootDirectory, { recursive: true, force: true })
.catch()
rmdirSync(rootDirectory, { recursive: true })
})

test('json reporter', async () => {
Expand Down Expand Up @@ -236,10 +234,10 @@ test('json reporter with outputFile', async () => {
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(outputFile, { recursive: true, force: true })
rmSync(outputFile)
})

test('json reporter with outputFile object', async () => {
Expand All @@ -260,10 +258,10 @@ test('json reporter with outputFile object', async () => {
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(outputFile, { force: true })
rmSync(outputFile)
})

test('json reporter with outputFile in non-existing directory', async () => {
Expand All @@ -283,10 +281,10 @@ test('json reporter with outputFile in non-existing directory', async () => {
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(rootDirectory, { recursive: true, force: true })
rmdirSync(rootDirectory, { recursive: true })
})

test('json reporter with outputFile object in non-existing directory', async () => {
Expand All @@ -308,10 +306,10 @@ test('json reporter with outputFile object in non-existing directory', async ()
// Assert
expect(normalizeCwd(context.output)).toMatchSnapshot()
expect(existsSync(outputFile)).toBe(true)
expect(await fs.readFile(outputFile, 'utf8')).toMatchSnapshot()
expect(readFileSync(outputFile, 'utf8')).toMatchSnapshot()

// Cleanup
await fs.rm(rootDirectory, { recursive: true, force: true })
rmdirSync(rootDirectory, { recursive: true })
})

/**
Expand Down

0 comments on commit 1d15efa

Please sign in to comment.