1
1
/* eslint-disable no-sparse-arrays */
2
2
import { AssertionError } from 'node:assert'
3
- import { fileURLToPath } from 'node:url'
4
- import { resolve } from 'node:path'
5
3
import { describe , expect , it , vi } from 'vitest'
6
4
import { generateToBeMessage , setupColors } from '@vitest/expect'
7
5
import { processError } from '@vitest/utils/error'
@@ -751,17 +749,13 @@ describe('async expect', () => {
751
749
} )
752
750
753
751
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>' )
757
752
try {
758
753
await expect ( Promise . resolve ( { foo : { bar : 42 } } ) ) . rejects . toThrow ( )
759
754
expect . unreachable ( )
760
755
}
761
756
catch ( err : any ) {
762
- const stack = err . stack . replace ( new RegExp ( root , 'g' ) , '<root>' )
763
757
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' )
765
759
}
766
760
767
761
try {
@@ -771,9 +765,8 @@ describe('async expect', () => {
771
765
expect . unreachable ( )
772
766
}
773
767
catch ( err : any ) {
774
- const stack = err . stack . replace ( new RegExp ( root , 'g' ) , '<root>' )
775
768
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' )
777
770
}
778
771
} )
779
772
0 commit comments