From 95bc89a057d2baf8e79068e108b6b16369f01c1f Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Fri, 18 Aug 2017 17:47:15 -0500 Subject: [PATCH] refactor: Place tests with features --- package.json | 9 +++++-- {test => src/shared}/environments.spec.ts | 2 +- .../exceptions}/http-exceptions.spec.ts | 2 +- tsconfig.json | 19 +++----------- tsconfig.spec.json | 25 +++++++++++++++++++ 5 files changed, 38 insertions(+), 19 deletions(-) rename {test => src/shared}/environments.spec.ts (88%) rename {test => src/shared/exceptions}/http-exceptions.spec.ts (98%) create mode 100644 tsconfig.spec.json diff --git a/package.json b/package.json index 0ef5659..1de9dce 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test:verbose": "npm run test -- --verbose", "test:coverage": "npm run clean:coverage && npm run test -- --coverage", "report-codeclimate": "codeclimate-test-reporter < coverage/lcov.info", - "lint": "tslint --type-check --project tsconfig.json -c ./tslint.json 'src/**/*.ts' --exclude 'src/**/*.d.ts'", + "lint": "tslint --type-check --project tsconfig.json -c ./tslint.json 'src/**/*.ts' --exclude 'src/**/*.d.ts' --exclude 'src/**/*.spec.ts'", "certs": "bash ./.ssl/generateLocalCerts.sh 'localhost'", "security": "nsp check", "transpile": "tsc" @@ -68,10 +68,15 @@ "typescript": "^2.4.2" }, "jest": { + "globals": { + "ts-jest": { + "tsConfigFile": "tsconfig.spec.json" + } + }, "transform": { ".(ts)": "/node_modules/ts-jest/preprocessor.js" }, - "testRegex": "(/test/.*|\\.(test|spec))\\.(ts|js)$", + "testRegex": "(/src/.*\\.spec)\\.ts", "moduleFileExtensions": [ "ts", "js", diff --git a/test/environments.spec.ts b/src/shared/environments.spec.ts similarity index 88% rename from test/environments.spec.ts rename to src/shared/environments.spec.ts index 4d599c6..205a32f 100644 --- a/test/environments.spec.ts +++ b/src/shared/environments.spec.ts @@ -1,4 +1,4 @@ -import { Environments } from '../src/shared/environments'; +import { Environments } from './environments'; describe('Environment', () => { test('getName() should return the test env', () => { diff --git a/test/http-exceptions.spec.ts b/src/shared/exceptions/http-exceptions.spec.ts similarity index 98% rename from test/http-exceptions.spec.ts rename to src/shared/exceptions/http-exceptions.spec.ts index b6fad0b..f01eaca 100644 --- a/test/http-exceptions.spec.ts +++ b/src/shared/exceptions/http-exceptions.spec.ts @@ -8,7 +8,7 @@ import { GoneException, UnsupportedMediaException, TooManyRequestsException, -} from '../src/shared/exceptions'; +} from '../../shared/exceptions'; describe('HTTP Exceptions', () => { test('BAD_REQUEST: Should have the correct properties', () => { diff --git a/tsconfig.json b/tsconfig.json index 84971d1..a4e9ddb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,24 +11,13 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", - "lib": [ - "es6", - "es2016.array.include" - ], + "lib": ["es6", "es2016.array.include"], "sourceMap": true, "allowJs": true, "pretty": true, "outDir": "./dist" }, - "typeRoots": [ - "node_modules/@types", - "src/core/types/*" - ], - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "**/*.spec.ts" - ] + "typeRoots": ["node_modules/@types", "src/core/types/*"], + "include": ["src/**/*"], + "exclude": ["node_modules", "**/*.spec.ts"] } diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000..f42abf1 --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,25 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "module": "commonjs", + "declaration": false, + "importHelpers": true, + "noImplicitAny": false, + "noImplicitThis": true, + "noUnusedLocals": true, + "removeComments": true, + "noLib": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es6", + "lib": [ + "es6", + "es2016.array.include" + ], + "sourceMap": true, + "allowJs": true, + "pretty": true + }, + "files": ["setupJest.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] +}