Skip to content

Commit f2ba160

Browse files
committed
chore: fix windows jest-expect test
1 parent e649d78 commit f2ba160

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

test/core/test/jest-expect.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* eslint-disable no-sparse-arrays */
22
import { AssertionError } from 'node:assert'
3-
import { fileURLToPath } from 'node:url'
4-
import { resolve } from 'node:path'
53
import { describe, expect, it, vi } from 'vitest'
64
import { generateToBeMessage, setupColors } from '@vitest/expect'
75
import { processError } from '@vitest/utils/error'
@@ -751,17 +749,13 @@ describe('async expect', () => {
751749
})
752750

753751
it('printing error message', async () => {
754-
const root = resolve(fileURLToPath(import.meta.url), '../../../../')
755-
// have "\" on windows, and "/" on unix
756-
const filename = fileURLToPath(import.meta.url).replace(root, '<root>')
757752
try {
758753
await expect(Promise.resolve({ foo: { bar: 42 } })).rejects.toThrow()
759754
expect.unreachable()
760755
}
761756
catch (err: any) {
762-
const stack = err.stack.replace(new RegExp(root, 'g'), '<root>')
763757
expect(err.message).toMatchInlineSnapshot('"promise resolved \\"{ foo: { bar: 42 } }\\" instead of rejecting"')
764-
expect(stack).toContain(`at ${filename}`)
758+
expect(err.stack).toContain('jest-expect.test.ts')
765759
}
766760

767761
try {
@@ -771,9 +765,8 @@ describe('async expect', () => {
771765
expect.unreachable()
772766
}
773767
catch (err: any) {
774-
const stack = err.stack.replace(new RegExp(root, 'g'), '<root>')
775768
expect(err.message).toMatchInlineSnapshot('"promise rejected \\"Error: some error { foo: { bar: 42 } }\\" instead of resolving"')
776-
expect(stack).toContain(`at ${filename}`)
769+
expect(err.stack).toContain('jest-expect.test.ts')
777770
}
778771
})
779772

0 commit comments

Comments
 (0)