Skip to content

Commit

Permalink
fix: toMatchInlineSnapshot fails when file path includes parentheses (
Browse files Browse the repository at this point in the history
fix #3370) (#3371)
  • Loading branch information
pacexy authored May 17, 2023
1 parent c44d991 commit dcf1346
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/utils/src/source-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function extractLocation(urlLike: string) {
return [urlLike]

const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/
const parts = regExp.exec(urlLike.replace(/[()]/g, ''))
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ''))
if (!parts)
return [urlLike]
return [parts[1], parts[2] || undefined, parts[3] || undefined]
Expand Down
18 changes: 18 additions & 0 deletions test/core/test/snapshot-inline-(parentheses).test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from 'vitest'

test('object', () => {
expect({
foo: {
type: 'object',
map: new Map(),
},
})
.toMatchInlineSnapshot(`
{
"foo": {
"map": Map {},
"type": "object",
},
}
`)
})

0 comments on commit dcf1346

Please sign in to comment.