From 1167ac80d74bb6fd963b28a38d8d844448917e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9odore=20L=C3=A9on?= Date: Thu, 29 May 2025 05:01:17 +0200 Subject: [PATCH] Add test coverage script (#929) ## Description: Added a command "npm run test:coverage" This could be added to the CI/CD to check if a pull request induced regressions, and if it added propers tests. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: theodoreleon.aetarax --- .gitignore | 1 + jest.config.ts | 10 ++++++++++ package.json | 1 + 3 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 90ce6e054..0cbd366d8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build/ node_modules/ out/ static/ +coverage/ TODO.txt resources/images/.DS_Store resources/.DS_Store diff --git a/jest.config.ts b/jest.config.ts index 02f05ddd8..bb15e1770 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -17,4 +17,14 @@ export default { }, transformIgnorePatterns: ["node_modules/(?!(node:)/)"], preset: "ts-jest/presets/default-esm", + collectCoverageFrom: ["src/**/*.ts", "!src/**/*.d.ts"], + coverageThreshold: { + global: { + branches: 0, + functions: 0, + lines: 0, + statements: 0, + }, + }, + coverageReporters: ["text", "lcov", "html"], }; diff --git a/package.json b/package.json index 2e2d02381..eedac982d 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dev": "cross-env GAME_ENV=dev concurrently \"npm run start:client\" \"npm run start:server-dev\"", "tunnel": "npm run build-prod && npm run start:server", "test": "jest", + "test:coverage": "jest --coverage", "format": "prettier --ignore-unknown --write .", "lint": "eslint", "lint:fix": "eslint --fix",