Skip to content

Commit 5ab4e51

Browse files
committed
test: verify onWritePath with explicit custom path
1 parent a5a2648 commit 5ab4e51

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/reporters/tests/github-actions.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { sep } from 'node:path'
12
import { resolve } from 'pathe'
23
import { describe, expect, it } from 'vitest'
34
import { GithubActionsReporter } from '../../../packages/vitest/src/node/reporters'
@@ -22,7 +23,11 @@ describe(GithubActionsReporter, () => {
2223
{
2324
reporters: new GithubActionsReporter({
2425
onWritePath(path) {
25-
return path.replace(resolve(__dirname, '..').replace(/:/g, '%3A'), '__TEST_DIR__')
26+
const normalized = path
27+
.replace(process.cwd(), '<process-cwd>')
28+
.replaceAll(sep, '/')
29+
30+
return `/some-custom-path/${normalized}`
2631
},
2732
}),
2833
root: './fixtures',
@@ -31,7 +36,7 @@ describe(GithubActionsReporter, () => {
3136
)
3237
expect(stdout).toMatchInlineSnapshot(`
3338
"
34-
::error file=__TEST_DIR__/fixtures/some-failing.test.ts,title=some-failing.test.ts > 3 + 3 = 7,line=8,column=17::AssertionError: expected 6 to be 7 // Object.is equality%0A%0A- Expected%0A+ Received%0A%0A- 7%0A+ 6%0A%0A ❯ some-failing.test.ts:8:17%0A%0A
39+
::error file=/some-custom-path/<process-cwd>/fixtures/some-failing.test.ts,title=some-failing.test.ts > 3 + 3 = 7,line=8,column=17::AssertionError: expected 6 to be 7 // Object.is equality%0A%0A- Expected%0A+ Received%0A%0A- 7%0A+ 6%0A%0A ❯ some-failing.test.ts:8:17%0A%0A
3540
"
3641
`)
3742
expect(stderr).toBe('')

0 commit comments

Comments
 (0)