Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mock): vi.mock with line breaks in arguments (#502)
- Loading branch information
1 parent
6d8c510
commit b7bc12f
Showing
4 changed files
with
152 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { assert, test, vi } from 'vitest' | ||
import { two } from '../src/submodule' | ||
import { timeout } from '../src/timeout' | ||
|
||
/* | ||
vi.mock('../src/timeout', () => ({ timeout: 0 })) | ||
/* */ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const text = ` | ||
vi.mock('../src/timeout', () => ({ timeout: 0 })) | ||
` | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const textComment = ` | ||
vi.mock('../src/timeout', () => ({ timeout: 0 })) | ||
/** | ||
vi.mock('../src/timeout', () => ({ timeout: 0 })) | ||
vi.mock('../src/timeout', () => ({ timeout: 0 })) | ||
*/ | ||
` | ||
|
||
vi.mock( | ||
'../src/submodule', | ||
() => ({ | ||
two: 55, | ||
}), | ||
) | ||
|
||
// vi.mock('../src/submodule') | ||
|
||
test('vitest correctly passes multiline vi.mock syntax', () => { | ||
assert.equal(55, two) | ||
assert.equal(100, timeout) | ||
}) |