From 06b579b689d7a562cf1463b09cd98923ada37599 Mon Sep 17 00:00:00 2001 From: John Martel Date: Tue, 27 Oct 2020 20:38:52 -0400 Subject: [PATCH] Configure Jest using Typescript This brings auto-completion to Jest configuration. See: https://github.com/facebook/jest/pull/10564 See: https://github.com/facebook/jest/issues/9636#issuecomment-604134083 --- jest.config.js => jest.config.ts | 5 ++++- package-lock.json | 31 +++++++++++++++++++++++++++++++ package.json | 2 ++ tsconfig.json | 5 ++++- 4 files changed, 41 insertions(+), 2 deletions(-) rename jest.config.js => jest.config.ts (84%) diff --git a/jest.config.js b/jest.config.ts similarity index 84% rename from jest.config.js rename to jest.config.ts index b384820..ef889b5 100644 --- a/jest.config.js +++ b/jest.config.ts @@ -1,4 +1,6 @@ -module.exports = { +import type { Config } from '@jest/types'; + +const config: Config.InitialOptions = { // this is a workaround since enabling coverage breaks sourceMaps // See: https://github.com/kulshekhar/ts-jest/issues/917 // See: https://github.com/facebook/jest/issues/5739 @@ -18,3 +20,4 @@ module.exports = { reporters: ['default', 'jest-junit'], testEnvironment: 'node', }; +export default config; diff --git a/package-lock.json b/package-lock.json index 34a5783..b02575b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1824,6 +1824,12 @@ "picomatch": "^2.0.4" } }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -2586,6 +2592,12 @@ "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, "diff-sequences": { "version": "26.5.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.5.0.tgz", @@ -8571,6 +8583,19 @@ } } }, + "ts-node": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.0.0.tgz", + "integrity": "sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, "tsconfig-paths": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", @@ -9047,6 +9072,12 @@ "camelcase": "^5.0.0", "decamelize": "^1.2.0" } + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true } } } diff --git a/package.json b/package.json index 563ce11..ef1ff3b 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "test:ci": "jest --coverage --ci" }, "devDependencies": { + "@jest/types": "26.6.1", "@types/jest": "26.0.15", "@typescript-eslint/eslint-plugin": "2.34.0", "@typescript-eslint/parser": "2.34.0", @@ -40,6 +41,7 @@ "prettier": "2.1.2", "rimraf": "3.0.2", "ts-jest": "26.4.2", + "ts-node": "9.0.0", "typescript": "4.0.3" }, "dependencies": { diff --git a/tsconfig.json b/tsconfig.json index 3d720c2..5890d67 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,5 +22,8 @@ "include": [ "src/**/*" ], - "compileOnSave": true + "compileOnSave": true, + "tsNode": { + "compiler": "typescript" + } }