Skip to content

Commit

Permalink
fix: edge case in node 20
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz committed Jan 9, 2024
1 parent e62fd1b commit 25c5df4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "docker",
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-20",
"containerEnv": {
"SHELL": "/bin/zsh"
}
}
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ if (!_beforeAll || !_afterAll) {
*/
export type SpiedInstance<TType extends {}> = {
[P in keyof TType]: Required<TType>[P] extends (...args: any[]) => any
? jest.SpyInstance<ReturnType<Required<TType>[P]>, jest.ArgsType<Required<TType>[P]>>
: never
? jest.SpyInstance<ReturnType<Required<TType>[P]>, jest.ArgsType<Required<TType>[P]>>
: never
}

/**
Expand All @@ -58,7 +58,7 @@ export function createRunner<TestComponents extends Record<string, any>>(
) {
return (name: string, suite: (testArgs: TestArguments<TestComponents>) => void) => {
let program: Lifecycle.ComponentBasedProgram<TestComponents>
let sandbox: sinon.SinonSandbox
let sandbox: sinon.SinonSandbox | null = null
const stubComponentInstances = new Map<keyof TestComponents, sinon.SinonStubbedInstance<any>>()
const spyComponentInstances = new Map<keyof TestComponents, SpiedInstance<any>>()

Expand Down Expand Up @@ -146,7 +146,7 @@ export function createRunner<TestComponents extends Record<string, any>>(
})

afterEach(() => {
sandbox.restore()
sandbox?.restore()
jest.restoreAllMocks()
})

Expand Down

0 comments on commit 25c5df4

Please sign in to comment.