diff --git a/.vscode/settings.json b/.vscode/settings.json index 53e056b595..909e67c9da 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,4 +12,7 @@ "[json]": { "editor.defaultFormatter": "vscode.json-language-features" }, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, } diff --git a/jest-preset.js b/jest-preset.js deleted file mode 100644 index 08016be7f6..0000000000 --- a/jest-preset.js +++ /dev/null @@ -1,16 +0,0 @@ -/** @type { import('@jest/types').Config.InitialOptions } */ -module.exports = { - collectCoverage: false, - globals: { - 'ts-jest': { - isolatedModules: false, - }, - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], - resetMocks: true, - resetModules: true, - testEnvironment: 'node', - testRegex: ['.+\\.test\\.tsx?$'], - transform: { '^.+\\.tsx?$': 'ts-jest' }, - verbose: false, -}; diff --git a/package-lock.json b/package-lock.json index f410242f3b..026f22c5b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24178,7 +24178,6 @@ "devDependencies": { "@grpc/grpc-js": "^1.10.10", "@grpc/proto-loader": "^0.7.13", - "@jest/globals": "^29.7.0", "@playwright/test": "1.43.0", "@ravanallc/grpc-server-reflection": "^0.1.6", "@types/concurrently": "^6.4.0", @@ -24195,7 +24194,6 @@ "faker": "^5.1.0", "graphql": "^16.8.1", "graphql-http": "^1.22.0", - "jest": "^29.7.0", "oidc-provider": "^8.4.5", "uuid": "^9.0.1", "ws": "^8.16.0", diff --git a/packages/insomnia-inso/jest.config.js b/packages/insomnia-inso/jest.config.js index 63c6712964..a87fb1349e 100644 --- a/packages/insomnia-inso/jest.config.js +++ b/packages/insomnia-inso/jest.config.js @@ -1,21 +1,27 @@ /** @type { import('@jest/types').Config.InitialOptions } */ module.exports = { - preset: '../../jest-preset.js', - globals: { - 'ts-jest': { - isolatedModules: true, - tsconfig: '../../tsconfig.base.json', - }, - }, - collectCoverage: false, - coveragePathIgnorePatterns: ['/node_modules/'], - coverageThreshold: { - global: { - branches: 80, - functions: 96, - lines: 95, - statements: 95, - }, + moduleFileExtensions: [ + 'js', + 'json', + 'jsx', + 'ts', + 'tsx', + ], + resetMocks: true, + resetModules: true, + testEnvironment: 'node', + testRegex: [ + '.+\\.test\\.tsx?$', + ], + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + isolatedModules: true, + }, + ], }, + verbose: false, + preset: 'ts-jest', setupFiles: ['./src/jest/setup.ts'], }; diff --git a/packages/insomnia-inso/src/__mocks__/cosmiconfig.ts b/packages/insomnia-inso/src/__mocks__/cosmiconfig.ts index e73d850acd..6033776c0d 100644 --- a/packages/insomnia-inso/src/__mocks__/cosmiconfig.ts +++ b/packages/insomnia-inso/src/__mocks__/cosmiconfig.ts @@ -1,3 +1,5 @@ +import { jest } from '@jest/globals'; + export const cosmiconfigSync = () => ({ load: jest.fn(), search: jest.fn(), diff --git a/packages/insomnia-inso/src/commands/__mocks__/insomnia-testing.ts b/packages/insomnia-inso/src/commands/__mocks__/insomnia-testing.ts index 6421443cb7..84a0179469 100644 --- a/packages/insomnia-inso/src/commands/__mocks__/insomnia-testing.ts +++ b/packages/insomnia-inso/src/commands/__mocks__/insomnia-testing.ts @@ -1,3 +1,5 @@ +import { jest } from '@jest/globals'; + export const generate = jest.fn(); export const generateToFile = jest.fn(); export const runTests = jest.fn(); diff --git a/packages/insomnia-inso/tsconfig.json b/packages/insomnia-inso/tsconfig.json index 9697f09598..d1afaae7ac 100644 --- a/packages/insomnia-inso/tsconfig.json +++ b/packages/insomnia-inso/tsconfig.json @@ -1,5 +1,27 @@ { - "extends": "../../tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "allowSyntheticDefaultImports": true, + "allowUnreachableCode": true, + "allowUnusedLabels": false, + "checkJs": true, + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "lib": ["DOM", "ES2019"], + "module": "CommonJS", + "moduleResolution": "node", + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true, + "resolveJsonModule": true, + "sourceMap": true, + "strict": true, + "target": "ES2019", + "types": ["node"], + "useUnknownInCatchVariables": false + }, "include": [ ".eslintrc.js", "esbuild.ts", diff --git a/packages/insomnia-sdk/jest.config.js b/packages/insomnia-sdk/jest.config.js index 0660b74f22..a777f2763c 100644 --- a/packages/insomnia-sdk/jest.config.js +++ b/packages/insomnia-sdk/jest.config.js @@ -1,11 +1,29 @@ /** @type { import('@jest/types').Config.InitialOptions } */ module.exports = { - preset: '../../jest-preset.js', - globals: { - 'ts-jest': { - isolatedModules: true, - tsconfig: '../../tsconfig.base.json', - }, + moduleFileExtensions: [ + 'js', + 'json', + 'jsx', + 'node', + 'ts', + 'tsx', + ], + resetMocks: true, + resetModules: true, + testEnvironment: 'node', + testRegex: [ + '.+\\.test\\.tsx?$', + ], + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + isolatedModules: true, + tsconfig: 'tsconfig.jest.json', + }, + ], }, + verbose: false, + preset: 'ts-jest', }; diff --git a/packages/insomnia-sdk/tsconfig.jest.json b/packages/insomnia-sdk/tsconfig.jest.json new file mode 100644 index 0000000000..2f98042715 --- /dev/null +++ b/packages/insomnia-sdk/tsconfig.jest.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "esModuleInterop": true + } +} diff --git a/packages/insomnia-smoke-test/jest.config.js b/packages/insomnia-smoke-test/jest.config.js deleted file mode 100644 index 0f631282ec..0000000000 --- a/packages/insomnia-smoke-test/jest.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type { import('@jest/types').Config.InitialOptions } */ -module.exports = { - preset: '../../jest-preset.js', -}; diff --git a/packages/insomnia-smoke-test/package.json b/packages/insomnia-smoke-test/package.json index d61856319e..c14df46663 100644 --- a/packages/insomnia-smoke-test/package.json +++ b/packages/insomnia-smoke-test/package.json @@ -21,7 +21,6 @@ "devDependencies": { "@grpc/grpc-js": "^1.10.10", "@grpc/proto-loader": "^0.7.13", - "@jest/globals": "^29.7.0", "@playwright/test": "1.43.0", "@ravanallc/grpc-server-reflection": "^0.1.6", "@types/concurrently": "^6.4.0", @@ -38,7 +37,6 @@ "graphql-http": "^1.22.0", "faker": "^5.1.0", "graphql": "^16.8.1", - "jest": "^29.7.0", "oidc-provider": "^8.4.5", "uuid": "^9.0.1", "ws": "^8.16.0", diff --git a/packages/insomnia-smoke-test/tsconfig.build.json b/packages/insomnia-smoke-test/tsconfig.build.json deleted file mode 100644 index 95ffaaa26e..0000000000 --- a/packages/insomnia-smoke-test/tsconfig.build.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "composite": true, - "outDir": "dist", - "rootDir": ".", - }, - "include": [ - "**/*.d.ts", - "cli", - "core", - "fixtures", - "modules", - "server", - ], - "exclude": [ - "**/*.test.ts", - "dist", - ], -} diff --git a/packages/insomnia-smoke-test/tsconfig.json b/packages/insomnia-smoke-test/tsconfig.json deleted file mode 100644 index ef7920a393..0000000000 --- a/packages/insomnia-smoke-test/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "./tsconfig.build.json", - "compilerOptions": { - "composite": false, - "rootDir": ".", - }, - "include": [ - "**/*.d.ts", - ".eslintrc.js", - "__jest__", - "cli", - "fixtures", - "jest.config.js", - "playwright", - "playwright.config.ts", - "server", - "tests", - ], - "exclude": [ - "dist", - ], -} diff --git a/packages/insomnia-testing/jest.config.js b/packages/insomnia-testing/jest.config.js index 0660b74f22..1e943773e8 100644 --- a/packages/insomnia-testing/jest.config.js +++ b/packages/insomnia-testing/jest.config.js @@ -1,11 +1,26 @@ /** @type { import('@jest/types').Config.InitialOptions } */ module.exports = { - preset: '../../jest-preset.js', - globals: { - 'ts-jest': { - isolatedModules: true, - tsconfig: '../../tsconfig.base.json', - }, + moduleFileExtensions: [ + 'js', + 'json', + 'jsx', + 'ts', + 'tsx', + ], + resetMocks: true, + resetModules: true, + testRegex: [ + '.+\\.test\\.tsx?$', + ], + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + isolatedModules: true, + tsconfig: 'tsconfig.jest.json', + }, + ], }, + preset: 'ts-jest', }; diff --git a/tsconfig.base.json b/packages/insomnia-testing/tsconfig.jest.json similarity index 86% rename from tsconfig.base.json rename to packages/insomnia-testing/tsconfig.jest.json index 99cd3138ea..167210bce9 100644 --- a/tsconfig.base.json +++ b/packages/insomnia-testing/tsconfig.jest.json @@ -8,7 +8,10 @@ "declaration": true, "declarationMap": true, "esModuleInterop": true, - "lib": ["DOM", "ES2019"], + "lib": [ + "DOM", + "ES2019" + ], "module": "CommonJS", "moduleResolution": "node", "noImplicitReturns": true, @@ -19,7 +22,9 @@ "sourceMap": true, "strict": true, "target": "ES2019", - "types": ["node"], + "types": [ + "node" + ], "useUnknownInCatchVariables": false - }, + } } diff --git a/packages/insomnia/jest.config.js b/packages/insomnia/jest.config.js index 962fc4d811..03f85637a8 100644 --- a/packages/insomnia/jest.config.js +++ b/packages/insomnia/jest.config.js @@ -2,29 +2,37 @@ const path = require('node:path'); /** @type { import('@jest/types').Config.InitialOptions } */ module.exports = { - preset: '../../jest-preset.js', - globals: { - 'ts-jest': { - isolatedModules: true, - }, + moduleFileExtensions: [ + 'js', + 'json', + 'jsx', + 'ts', + 'tsx', + ], + resetMocks: true, + resetModules: true, + testRegex: [ + '.+\\.test\\.tsx?$', + ], + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + isolatedModules: true, + }, + ], }, + preset: 'ts-jest', cache: false, modulePathIgnorePatterns: ['./src/network/.*/__mocks__'], transformIgnorePatterns: ['/node_modules/(?!(@getinsomnia/api-client)/)'], setupFiles: ['./src/__jest__/setup.ts'], setupFilesAfterEnv: ['./src/__jest__/setup-after-env.ts'], testEnvironment: 'jsdom', - verbose: true, + verbose: false, moduleNameMapper: { '\\.(css|less|png|svg)$': '/src/__mocks__/dummy.ts', 'styled-components': path.join(__dirname, '../../node_modules/styled-components'), 'jsonpath-plus': path.join(__dirname, '../../node_modules/jsonpath-plus/dist/index-node-cjs.cjs'), }, - collectCoverage: !!process.env.CI, - collectCoverageFrom: ['src/account/**/*.ts', 'src/common/**/*.ts', 'src/main/**/*.ts', 'src/models/**/*.ts', 'src/network/**/*.ts', 'src/sync/**/*.ts', 'src/templating/**/*.ts', 'src/utils/**/*.ts'], - coverageThreshold: { - global: { - lines: 35, - }, - }, }; diff --git a/packages/insomnia/tsconfig.build.json b/packages/insomnia/tsconfig.build.json index 83508fed93..7e9e3cde35 100644 --- a/packages/insomnia/tsconfig.build.json +++ b/packages/insomnia/tsconfig.build.json @@ -1,6 +1,24 @@ { - "extends": "../../tsconfig.base.json", "compilerOptions": { + "allowJs": true, + "allowSyntheticDefaultImports": true, + "allowUnreachableCode": true, + "allowUnusedLabels": false, + "checkJs": true, + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "moduleResolution": "node", + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true, + "resolveJsonModule": true, + "sourceMap": true, + "strict": true, + "target": "ES2019", + "useUnknownInCatchVariables": false, + "lib": ["DOM.Iterable", "DOM"], "isolatedModules": true, "jsx": "react", diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json deleted file mode 100644 index a4887a36df..0000000000 --- a/tsconfig.eslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "include": [ - ".eslintrc.js", - "jest-preset.js", - ], -}