From dcee7ac5a5fffb157ccf60d35453aefbc5eb9817 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 9 Oct 2018 20:22:39 -0400 Subject: [PATCH] fix: jest.config file to properly run tests again. Follow up issue to fix these exceptions --- jest.config.js | 35 ++++++++++++++++------------- package-lock.json | 30 ++++++++++++------------- package.json | 10 ++++----- src/infrastructure/Bundler.ts | 2 +- test/tests/infrastructure/Bundle.ts | 6 ++--- 5 files changed, 43 insertions(+), 40 deletions(-) diff --git a/jest.config.js b/jest.config.js index 944f2022..5b4478cc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,18 +1,21 @@ module.exports = { - coverageDirectory: './coverage/', - collectCoverage: true, - testURL: 'http://localhost/', - setupTestFrameworkScriptFile: 'jest-extended', - reporters: ['jest-tap-reporter'], - testRegex: '(/__tests__/.*|/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$', - "transform": { - "^.+\\.tsx?$": "ts-jest" - }, - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json" - ] + preset: 'ts-jest', + + testEnvironment: 'node', + testRegex: '(/__tests__/.*|/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$', + testMatch: null, + testURL: 'http://localhost/', + + coverageDirectory: './coverage/', + collectCoverage: true, + + setupTestFrameworkScriptFile: 'jest-extended', + + globals: { + 'ts-jest': { + diagnostics: { + ignoreCodes: [2445, 7006, 7031, 2339, 7016, 7023, 7017] + }, + }, + }, }; diff --git a/package-lock.json b/package-lock.json index 92a99e9e..1c9d418e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -724,7 +724,7 @@ }, "babel-plugin-istanbul": { "version": "4.1.6", - "resolved": "http://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz", "integrity": "sha512-PWP9FQ1AhZhS01T/4qLSKoHGY/xvkZdVBGlKM/HuxxS3+sC66HhTNR7+MpbO/so/cz/wY94MeSWJuP1hXIPfwQ==", "dev": true, "requires": { @@ -787,7 +787,7 @@ }, "babel-plugin-syntax-object-rest-spread": { "version": "6.13.0", - "resolved": "http://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", "dev": true }, @@ -2784,7 +2784,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, @@ -3551,7 +3551,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -4861,7 +4861,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, @@ -4936,7 +4936,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -5377,7 +5377,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -5386,7 +5386,7 @@ "dependencies": { "minimist": { "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true } @@ -9103,7 +9103,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true } @@ -9215,7 +9215,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, @@ -9725,7 +9725,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -10810,7 +10810,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -11397,7 +11397,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { @@ -11427,7 +11427,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -11504,7 +11504,7 @@ }, "yargs": { "version": "11.1.0", - "resolved": "http://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", "integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==", "dev": true, "requires": { diff --git a/package.json b/package.json index c304d19a..9550b8bf 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "test:bundles": "jest test/tests/bundles", "test:infrastructure": "jest test/tests/infrastructure", "test:services": "jest test/tests/services", - "test": "jest && codecov", + "test": "jest --debug && codecov", "prepublishOnly": "npm run build", "semantic-release": "semantic-release" }, @@ -52,22 +52,22 @@ "@semantic-release/npm": "^5.0.4", "@types/humps": "^1.1.2", "@types/jest": "^23.3.5", - "@types/qs": "^6.5.1", "@types/parse-link-header": "^1.0.0", + "@types/qs": "^6.5.1", "@types/request-promise": "^4.1.42", "@types/url-join": "^0.8.2", "@types/util.promisify": "^1.0.0", - "semantic-release": "^15.9.17", "codecov": "^3.1.0", - "husky": "^1.1.1", "cz-conventional-changelog": "^2.1.0", + "husky": "^1.1.1", "jest": "^23.6.0", "jest-extended": "^0.11.0", "jest-tap-reporter": "^1.9.0", + "semantic-release": "^15.9.17", "ts-jest": "^23.10.4", "tslint": "^5.11.0", "tslint-config-airbnb": "^5.11.0", - "typescript": "3.1.2" + "typescript": "^3.1.2" }, "dependencies": { "humps": "^2.0.1", diff --git a/src/infrastructure/Bundler.ts b/src/infrastructure/Bundler.ts index 3f4666dd..81fce642 100644 --- a/src/infrastructure/Bundler.ts +++ b/src/infrastructure/Bundler.ts @@ -2,7 +2,7 @@ function Bundler(services = {}) { const combined = { ...services }; return class Bundle { - constructor(options) { + constructor(options = {}) { Object.keys(combined).forEach((serviceName) => { this[serviceName] = new combined[serviceName](options); }); diff --git a/test/tests/infrastructure/Bundle.ts b/test/tests/infrastructure/Bundle.ts index d940f073..13bd4722 100644 --- a/test/tests/infrastructure/Bundle.ts +++ b/test/tests/infrastructure/Bundle.ts @@ -1,13 +1,13 @@ import { Bundler } from '../../../src/infrastructure'; class Test1 { - constructor(value) { + constructor(value: number) { this.value = value * 3; } } class Test2 { - constructor(value) { + constructor(value: number) { this.value = value * 2; } } @@ -15,7 +15,7 @@ class Test2 { test('No classes passed to Bundler returns an empty Bundle', async () => { const Bundle = Bundler(); const services = new Bundle(); - + expect(services).toEqual({}); });