Skip to content

Commit

Permalink
fix: toMatchInlineSnapshot fails when used in a file path with pare…
Browse files Browse the repository at this point in the history
…ntheses vitest-dev#3370
  • Loading branch information
pacexy committed May 14, 2023
1 parent 4a807df commit 1588b66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/utils/src/source-map.ts
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
19 changes: 19 additions & 0 deletions test/core/test/snapshot-inline-(parentheses).test.ts
@@ -0,0 +1,19 @@
import { expect, test } from 'vitest'

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

0 comments on commit 1588b66

Please sign in to comment.