From 8875bd43eb83244833719278fa4a335ed54f46b5 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Wed, 4 Sep 2024 13:55:39 +0300 Subject: [PATCH 1/3] chore: use `@jest/globals` instead of `@types/jest` --- jest.config.js | 4 +++- package-lock.json | 13 ++----------- package.json | 2 +- tests/global-createArgument.test.ts | 1 + tests/global-createCommand.test.ts | 1 + tests/global-createOption.test.ts | 1 + tsconfig.json | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/jest.config.js b/jest.config.js index ef552ba..d701910 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,8 @@ +/** @type {import('jest').Config} */ const config = { - testEnvironment: 'node', collectCoverage: true, + injectGlobals: true, + testEnvironment: 'node', transform: { '^.+\\.tsx?$': ['ts-jest'], }, diff --git a/package-lock.json b/package-lock.json index ec0efd7..72df49f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "12.1.0", "license": "MIT", "devDependencies": { - "@types/jest": "^29.2.6", + "@jest/globals": "^29.3.1", "@types/node": "^20.11.7", "commander": "~12.1.0", "eslint": "^8.57.0", @@ -965,6 +965,7 @@ "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", "dev": true, + "license": "MIT", "dependencies": { "@jest/environment": "^29.7.0", "@jest/expect": "^29.7.0", @@ -1323,16 +1324,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/jest": { - "version": "29.5.12", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz", - "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", - "dev": true, - "dependencies": { - "expect": "^29.0.0", - "pretty-format": "^29.0.0" - } - }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", diff --git a/package.json b/package.json index 1763e3a..d0d2e3b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "commander": "~12.1.0" }, "devDependencies": { - "@types/jest": "^29.2.6", + "@jest/globals": "^29.3.1", "@types/node": "^20.11.7", "commander": "~12.1.0", "eslint": "^8.57.0", diff --git a/tests/global-createArgument.test.ts b/tests/global-createArgument.test.ts index 3283219..96864e9 100644 --- a/tests/global-createArgument.test.ts +++ b/tests/global-createArgument.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from '@jest/globals'; import { createArgument } from '..'; test('when createArgument without description then argument has name', () => { diff --git a/tests/global-createCommand.test.ts b/tests/global-createCommand.test.ts index 625a442..8535dbb 100644 --- a/tests/global-createCommand.test.ts +++ b/tests/global-createCommand.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from '@jest/globals'; import { createCommand } from '..'; test('when createCommand without name then command has empty name', () => { diff --git a/tests/global-createOption.test.ts b/tests/global-createOption.test.ts index d1fdbf9..6200740 100644 --- a/tests/global-createOption.test.ts +++ b/tests/global-createOption.test.ts @@ -1,3 +1,4 @@ +import { expect, test } from '@jest/globals'; import { createOption } from '..'; test('when createOption without description then option has flags', () => { diff --git a/tsconfig.json b/tsconfig.json index 3bda6f3..39dd1fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": ["es6"], - "types": ["node", "jest"], + "types": ["node"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From f974a2b5e784d4b869efc4cd7c2af117ac34f16f Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Wed, 4 Sep 2024 14:39:02 +0300 Subject: [PATCH 2/3] revert --- package-lock.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 72df49f..fb07c4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -965,7 +965,6 @@ "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", "dev": true, - "license": "MIT", "dependencies": { "@jest/environment": "^29.7.0", "@jest/expect": "^29.7.0", From 4f578dbb68b77e697899a2c8ed87238cb81fa9ee Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Fri, 6 Sep 2024 07:22:10 +0300 Subject: [PATCH 3/3] fix `injectGlobals` --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index d701910..159ae6b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ /** @type {import('jest').Config} */ const config = { collectCoverage: true, - injectGlobals: true, + injectGlobals: false, testEnvironment: 'node', transform: { '^.+\\.tsx?$': ['ts-jest'],