Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: can mock non-existent paths and virtual modules via __mocks__ (#…
- Loading branch information
1 parent
7f068b5
commit c491fb4
Showing
5 changed files
with
49 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const value = 'folder' |
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 @@ | ||
export const folder = true |
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,24 @@ | ||
// @ts-expect-error vscode is not installed | ||
import * as vscodeMocks from 'vscode-mocks' | ||
// @ts-expect-error vscode is not installed | ||
import * as vscodeFactory from 'vscode-factory' | ||
// @ts-expect-error virtual module | ||
import * as virtual from 'virtual-module' | ||
|
||
vi.mock('vscode-mocks') | ||
vi.mock('vscode-factory', () => { | ||
return { factory: true } | ||
}) | ||
vi.mock('virtual-module') | ||
|
||
it('mocks not installed in mocks folder', () => { | ||
expect(vscodeMocks.folder).toBe(true) | ||
}) | ||
|
||
it('mocks not installed in mocks factory', () => { | ||
expect(vscodeFactory.factory).toBe(true) | ||
}) | ||
|
||
it('mocks virtual modules in mocks folder', () => { | ||
expect(virtual.value).toBe('folder') | ||
}) |
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