Skip to content

Commit a0f9ae3

Browse files
authored
fix(mocker): fix regexpHoistable to allow whitespace before parentheses (#8231)
1 parent 37cc269 commit a0f9ae3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/mocker/src/node/hoistMocksPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function hoistMocksPlugin(options: HoistMocksPluginOptions = {}): Plugin
6868
])
6969

7070
const regexpHoistable = new RegExp(
71-
`\\b(?:${utilsObjectNames.join('|')})\\s*\.\\s*(?:${Array.from(methods).join('|')})\\(`,
71+
`\\b(?:${utilsObjectNames.join('|')})\\s*\.\\s*(?:${Array.from(methods).join('|')})\\s*\\(`,
7272
)
7373

7474
return {
@@ -120,7 +120,7 @@ function getNodeTail(code: string, node: Node) {
120120
}
121121

122122
const regexpHoistable
123-
= /\b(?:vi|vitest)\s*\.\s*(?:mock|unmock|hoisted|doMock|doUnmock)\(/
123+
= /\b(?:vi|vitest)\s*\.\s*(?:mock|unmock|hoisted|doMock|doUnmock)\s*\(/
124124
const hashbangRE = /^#!.*\n/
125125

126126
export interface HoistMocksResult {

test/core/test/tab-effect.spec.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test('Are you mocking me?', () => {
1010
// note there are NO indents in this file
1111
// except the next line
1212
// test pass with spaces, test fails with tab
13-
vi.mock('node:path', () => {
13+
vi.mock ('node:path', () => {
1414
return {
1515
join: vi.fn().mockReturnValue('goodbye world')
1616
}

0 commit comments

Comments
 (0)