From 41bb85c984b415ac0aa36a39f7e4f136e1e129bd Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Sun, 13 Dec 2020 16:54:09 +0100 Subject: [PATCH] jest tests back + vscode --- .gitignore | 1 - .vscode/launch.json | 20 ++++++++++++++++++++ bin.tsconfig.json | 2 +- jest.config.js | 26 ++++++++------------------ package.json | 2 +- spec/elasticsearch.jest.ts | 4 +++- tsconfig.jest.json | 3 --- 7 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 .vscode/launch.json delete mode 100644 tsconfig.jest.json diff --git a/.gitignore b/.gitignore index 8544c27..4179018 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,5 @@ dist/ dist-test/ node_modules/ npm-debug.log -.vscode/ lib/ bin/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..38a5476 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Jest All", + "program": "${workspaceFolder}/node_modules/.bin/jest", + "args": [ + "--runInBand" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "disableOptimisticBPs": true, + "windows": { + "program": "${workspaceFolder}/node_modules/jest/bin/jest", + } + } + ] +} \ No newline at end of file diff --git a/bin.tsconfig.json b/bin.tsconfig.json index bb6e0cd..8af8ab6 100644 --- a/bin.tsconfig.json +++ b/bin.tsconfig.json @@ -6,5 +6,5 @@ "outFile": "bin/tsdb-kit.js" }, "include": [ "src/**/*.ts" ], - "exclude": [ "src/index.ts" ] + "exclude": [ "src/index.ts" ] } diff --git a/jest.config.js b/jest.config.js index 4f0f1e2..0c8cb56 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,21 +1,11 @@ module.exports = { - "verbose": true, - "globals": { - "ts-jest": { - "useBabelrc": true, - "tsConfigFile": "tsconfig.jest.json" - } - }, - "transform": { - "\\.ts": "ts-jest" - }, - "testRegex": "(\\.|/)([jt]est)\\.[jt]s$", - "moduleFileExtensions": [ - "ts", - "js", - "json" - ], - "setupFiles": [ + verbose: true, + preset: 'ts-jest', + testEnvironment: 'node', + setupFiles: [ "/spec/setup_tests.ts" - ] + ], + // TODO: folder structure defualt for jest, so + // no preference about the testRegex + testRegex: "(\\.|/)([jt]est)\\.[jt]s$" }; diff --git a/package.json b/package.json index 77609b1..38a9d7a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build:lib": "tsc --p lib.tsconfig.json", "build:bin": "tsc --p bin.tsconfig.json", "dev": "tsc -w", - "test": "ts-jest" + "test": "jest " }, "repository": { "type": "git", diff --git a/spec/elasticsearch.jest.ts b/spec/elasticsearch.jest.ts index cb797da..6429735 100644 --- a/spec/elasticsearch.jest.ts +++ b/spec/elasticsearch.jest.ts @@ -179,7 +179,9 @@ describe('simple query', function(){ let limit = 222; let offset = 333; - expect(elasticMetric.getQuery(from, to, limit, offset)).toEqual(expectedQuery); + let result = elasticMetric.getQuery(from, to, limit, offset); + + expect(result).toEqual(expectedQuery); }); diff --git a/tsconfig.jest.json b/tsconfig.jest.json deleted file mode 100644 index 1c66acf..0000000 --- a/tsconfig.jest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./tsconfig" -}