From 2e403de0032ed8bf16715b3f3b84a7fd244775c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Susana=20V=C3=A1zquez?= <3016283+svazquezco@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:15:23 +0100 Subject: [PATCH] fix(frontend): declare the test globals for ts-jest ts-jest compiles each test file with its own program and drops the automatic `@types/*` inclusion, so whichever suite jest compiles first fails to type-check with "Cannot find name 'jest'". Declaring the globals in the transform's tsconfig makes every suite compile whatever order jest runs them in. The problem is latent in the template rather than new: any suite fails the same way when it is the first one compiled. It surfaces now because jest's default sequencer runs the largest test file first, and the deferrable example makes `useAgreementSync.test.ts` that file. --- frontend/jest.config.cjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/jest.config.cjs b/frontend/jest.config.cjs index 190e420..6896a3a 100644 --- a/frontend/jest.config.cjs +++ b/frontend/jest.config.cjs @@ -7,6 +7,12 @@ module.exports = { '\\.scss$': '/__mocks__/styleMock.js', }, transform: { - '^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: { esModuleInterop: true } }], + // ts-jest compiles each file with its own program and drops the automatic `@types/*` + // inclusion, so whichever suite jest compiles first fails with "Cannot find name + // 'jest'". Declaring the test globals here makes every suite compile in any order. + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { tsconfig: { esModuleInterop: true, types: ['jest', '@testing-library/jest-dom'] } }, + ], }, };