From 25c5df440ad16aaa5b5f7f2e91d5dc20814ff30e Mon Sep 17 00:00:00 2001 From: menduz Date: Mon, 8 Jan 2024 23:49:53 -0300 Subject: [PATCH] fix: edge case in node 20 --- .devcontainer/devcontainer.json | 7 +++++++ src/index.ts | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..2fa526d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,7 @@ +{ + "name": "docker", + "image": "mcr.microsoft.com/devcontainers/typescript-node:0-20", + "containerEnv": { + "SHELL": "/bin/zsh" + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index f2ca8a3..fc60334 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,8 +44,8 @@ if (!_beforeAll || !_afterAll) { */ export type SpiedInstance = { [P in keyof TType]: Required[P] extends (...args: any[]) => any - ? jest.SpyInstance[P]>, jest.ArgsType[P]>> - : never + ? jest.SpyInstance[P]>, jest.ArgsType[P]>> + : never } /** @@ -58,7 +58,7 @@ export function createRunner>( ) { return (name: string, suite: (testArgs: TestArguments) => void) => { let program: Lifecycle.ComponentBasedProgram - let sandbox: sinon.SinonSandbox + let sandbox: sinon.SinonSandbox | null = null const stubComponentInstances = new Map>() const spyComponentInstances = new Map>() @@ -146,7 +146,7 @@ export function createRunner>( }) afterEach(() => { - sandbox.restore() + sandbox?.restore() jest.restoreAllMocks() })