Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow reassigning global mocks #792

Merged
merged 1 commit into from Feb 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/vitest/src/node/mocker.ts
Expand Up @@ -72,18 +72,18 @@ export class VitestMocker {
(this.callbacks[event] ?? []).forEach(fn => fn(...args))
}

public getSuiteFilepath() {
public getSuiteFilepath(): string {
return __vitest_worker__?.filepath || 'global'
}

public getMocks() {
const suite = this.getSuiteFilepath()
const suiteMocks = this.mockMap[suite || '']
const suiteMocks = this.mockMap[suite]
const globalMocks = this.mockMap.global

return {
...suiteMocks,
...globalMocks,
...suiteMocks,
}
}

Expand Down