Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fenghan34 committed Feb 5, 2024
1 parent f09904e commit 066b725
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { describe, test } from "vitest";

describe('space 1', () => {
test('base', () => {})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { describe, test } from "vitest";

describe('space 2', () => {
test('base', () => {})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineWorkspace } from "vitest/config";

export default defineWorkspace(['space-1', 'space-2'])
10 changes: 10 additions & 0 deletions test/reporters/tests/junit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ test('emits <failure> when beforeAll/afterAll failed', async () => {
stdout = stdout.replaceAll(/(timestamp|hostname|time)=".*?"/g, '$1="..."')
expect(stdout).toMatchSnapshot()
})

test('write testsuite name relative to root config', async () => {
let { stdout } = await runVitest({ reporters: 'junit', root: './fixtures/better-testsuite-name' })
stdout = stdout.replaceAll(/(timestamp|hostname|time)=".*?"/g, '$1="..."')

const space1 = '<testsuite name="space-1/test/base.test.ts" timestamp="..." hostname="..." tests="1" failures="0" errors="0" skipped="0" time="...">'
const space2 = '<testsuite name="space-2/test/base.test.ts" timestamp="..." hostname="..." tests="1" failures="0" errors="0" skipped="0" time="...">'
expect(stdout).toContain(space1)
expect(stdout).toContain(space2)
})

0 comments on commit 066b725

Please sign in to comment.