Adding jest unit testing framework and required sonar config

This commit is contained in:
Patrick Müller 2022-06-25 12:21:48 +02:00
parent a9ad5e8f87
commit 137428ffa7
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE
6 changed files with 8900 additions and 78 deletions

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ dist/
logs/
node_modules/
public/
coverage/
testResults/

5
jest.config.js Normal file
View File

@ -0,0 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

8951
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
"start": "tsc && node ./dist/app.js",
"build": "tsc",
"debug": "export DEBUG=* && npm run start",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest --coverage --testResultsProcessor ./node_modules/jest-sonar-reporter/index.js"
},
"keywords": [],
"author": "",
@ -32,12 +32,22 @@
"@types/bcrypt": "^3.0.1",
"@types/debug": "^4.1.5",
"@types/express": "^4.17.11",
"@types/jest": "^28.1.3",
"@types/random-words": "^1.1.2",
"@types/swagger-jsdoc": "^6.0.1",
"@types/swagger-ui-express": "^4.1.3",
"@types/winston": "^2.4.4",
"jest": "^28.1.1",
"jest-sonar-reporter": "^2.0.0",
"source-map-support": "^0.5.19",
"ts-jest": "^28.0.5",
"tslint": "^6.1.3",
"typescript": "^4.1.5"
},
"jestSonar": {
"sonar56x": true,
"reportPath": "testResults",
"reportFile": "sonar-report.xml",
"indent": 4
}
}

View File

@ -1 +1,6 @@
sonar.projectKey=pd-api
sonar.sources=src
sonar.tests=test
sonar.language=ts
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=testResults/sonar-report.xml

3
test/template.test.ts Normal file
View File

@ -0,0 +1,3 @@
test('Test template', async () => {
expect(true).toBe(true);
});