Skip to content

Commit

Permalink
refactor: removed not needed code
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 3, 2022
1 parent ad98f6a commit 3d92513
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
6 changes: 1 addition & 5 deletions packages/vitest/src/runtime/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ export async function executeInViteNode(options: ExecuteOptions & { files: strin
}

export class VitestRunner extends ViteNodeRunner {
mocker: VitestMocker
entries = new Set<string>()

constructor(public options: ExecuteOptions) {
super(options)
this.mocker = new VitestMocker(options, this.moduleCache)
}

prepareContext(context: Record<string, any>) {
const request = context.__vite_ssr_import__
const resolveId = context.__vitest_resolve_id__

const mocker = this.mocker.withRequest(request)
const mocker = new VitestMocker(this.options, this.moduleCache, request)

const workerState = getWorkerState()

Expand Down
12 changes: 2 additions & 10 deletions packages/vitest/src/runtime/mocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ export class VitestMocker {
private static pendingIds: PendingSuiteMock[] = []
private static spyModule?: typeof import('../integrations/spy')

private request!: ViteRunnerRequest

constructor(
public options: ExecuteOptions,
private moduleCache: ModuleCacheMap,
request?: ViteRunnerRequest,
) {
this.request = request!
}
private request: ViteRunnerRequest,
) {}

private get root() {
return this.options.root
Expand Down Expand Up @@ -262,8 +258,4 @@ export class VitestMocker {
public queueUnmock(id: string, importer: string) {
VitestMocker.pendingIds.push({ type: 'unmock', id, importer })
}

public withRequest(request: ViteRunnerRequest) {
return new VitestMocker(this.options, this.moduleCache, request)
}
}

0 comments on commit 3d92513

Please sign in to comment.