From f289260a6ac9f070b916126fb883962b3abb68d8 Mon Sep 17 00:00:00 2001 From: paulgs9988 Date: Tue, 16 Jul 2024 16:34:39 -0600 Subject: [PATCH] updating configs for coverage report generation --- .babelrc | 7 +++++++ jest.config.js | 16 ++++++++++++++-- package-lock.json | 6 +++++- package.json | 5 +++-- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..3265e9d7 --- /dev/null +++ b/.babelrc @@ -0,0 +1,7 @@ +{ + "presets": [ + ["@babel/preset-env", { "targets": { "node": "current" } }], + "@babel/preset-typescript" + ] + } + \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index cf81ff9b..810c0546 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,19 @@ module.exports = { testEnvironment: 'node', testMatch: ['**/__tests__/**/*.test.ts'], moduleNameMapper: { - '^@/(.*)$': '/src/$1' + '^@/(.*)$': '/src/$1' }, testTimeout: 20000, -}; + collectCoverage: true, + coverageDirectory: 'coverage', + coverageReporters: ['text', 'lcov'], + coveragePathIgnorePatterns: [ + "/node_modules/", + "/dist/", + "/src/server.js" + ], + transform: { + "^.+\\.(ts|tsx)$": "ts-jest", + }, + }; + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index db2e1a70..5a579319 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,6 +38,9 @@ "ws": "8.13.0" }, "devDependencies": { + "@babel/core": "^7.24.8", + "@babel/preset-env": "^7.24.8", + "@babel/preset-typescript": "^7.24.7", "@types/better-sqlite3": "7.5.0", "@types/cookie-parser": "1.4.3", "@types/cors": "2.8.13", @@ -50,11 +53,12 @@ "@types/ws": "8.5.4", "@typescript-eslint/eslint-plugin": "5.46.1", "@typescript-eslint/parser": "5.60.1", + "babel-jest": "^29.7.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-no-unsanitized": "4.0.2", "eslint-plugin-security": "1.5.0", "eslint-plugin-xss": "0.1.12", - "jest": "29.7.0", + "jest": "^29.7.0", "nodemon": "2.0.22", "supertest": "7.0.0", "ts-jest": "29.2.2" diff --git a/package.json b/package.json index dc796bcf..ac2ba78a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "JSON RPC server for Shardeum", "main": "src/server.js", "scripts": { - "test": "NODE_ENV=test jest --detectOpenHandles --silent", + "test": "NODE_ENV=test jest --detectOpenHandles --silent --forceExit", "start": "npm run compile && node dist/src/server.js", "dev": "nodemon", "compile": "tsc -p .", @@ -13,7 +13,8 @@ "lint-windows": "eslint ./src/**/*.ts", "update-docker-dev": "docker build -t registry.gitlab.com/shardeum/json-rpc-server:dev . --push", "format-check": "prettier --check './src/**/*.ts'", - "local:test": "bash run_tests.sh" + "local:test": "bash run_tests.sh", + "coverage": "jest --coverage --detectOpenHandles --forceExit --silent" }, "author": "thantsintoe", "license": "ISC",