Adding feature unit tests package.json and also adding unit tests steps in Jenkinsfile.
This commit is contained in:
parent
dd60c938e6
commit
a51175c92a
|
|
@ -12,7 +12,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Chechout Node.js and npm') {
|
||||
stage('Check Node.js and npm') {
|
||||
steps {
|
||||
script {
|
||||
sh "node -v"
|
||||
|
|
@ -27,6 +27,12 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Run Unit Tests') {
|
||||
steps {
|
||||
sh 'npm run test -- --coverage --reporters=jest-junit'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Project') {
|
||||
steps {
|
||||
sh 'npm run build'
|
||||
|
|
@ -36,14 +42,16 @@ pipeline {
|
|||
|
||||
post {
|
||||
always {
|
||||
cleanWs(cleanWhenNotBuilt: false,
|
||||
notFailBuild: true)
|
||||
cleanWs(cleanWhenNotBuilt: false, notFailBuild: true)
|
||||
}
|
||||
success {
|
||||
echo 'Build completed successfully!'
|
||||
junit 'reports/junit.xml'
|
||||
archiveArtifacts artifacts: 'reports/**', fingerprint: true
|
||||
}
|
||||
failure {
|
||||
echo 'Build failed!'
|
||||
junit 'reports/junit.xml' // Ensures test results are captured even on failure
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,13 @@
|
|||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": ["{options.outputFile}"]
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/frontend/jest.config.ts"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@
|
|||
"jest": "29.7.0",
|
||||
"jest-environment-jsdom": "29.7.0",
|
||||
"jest-environment-node": "^29.4.1",
|
||||
"jest-junit": "^16.0.0",
|
||||
"jsdom": "~22.1.0",
|
||||
"postcss": "8.4.38",
|
||||
"prettier": "^2.6.2",
|
||||
|
|
@ -30162,6 +30163,45 @@
|
|||
"fsevents": "^2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-junit": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-16.0.0.tgz",
|
||||
"integrity": "sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"mkdirp": "^1.0.4",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"uuid": "^8.3.2",
|
||||
"xml": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-junit/node_modules/mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-junit/node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/jest-leak-detector": {
|
||||
"version": "29.7.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz",
|
||||
|
|
@ -47790,6 +47830,13 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xml": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
||||
"integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xml-name-validator": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",
|
||||
|
|
|
|||
17
package.json
17
package.json
|
|
@ -29,7 +29,13 @@
|
|||
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push --force-reset && npx prisma db push",
|
||||
"docker-build": "./var/docker/docker-build.sh",
|
||||
"docker-create": "./var/docker/docker-create.sh",
|
||||
"postinstall": "npm run update-plugins && npm run prisma-generate"
|
||||
"postinstall": "npm run update-plugins && npm run prisma-generate",
|
||||
"test": "npx nx run-many --target=test --projects=frontend,backend,workers,cron,commands --parallel=5",
|
||||
"test:frontend": "npx nx run frontend:test",
|
||||
"test:backend": "npx nx run backend:test",
|
||||
"test:workers": "npx nx run workers:test",
|
||||
"test:cron": "npx nx run cron:test",
|
||||
"test:commands": "npx nx run commands:test"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
|
@ -221,6 +227,7 @@
|
|||
"jest": "29.7.0",
|
||||
"jest-environment-jsdom": "29.7.0",
|
||||
"jest-environment-node": "^29.4.1",
|
||||
"jest-junit": "^16.0.0",
|
||||
"jsdom": "~22.1.0",
|
||||
"postcss": "8.4.38",
|
||||
"prettier": "^2.6.2",
|
||||
|
|
@ -235,5 +242,11 @@
|
|||
},
|
||||
"volta": {
|
||||
"node": "20.17.0"
|
||||
}
|
||||
},
|
||||
"jest": {
|
||||
"reporters": [
|
||||
"default",
|
||||
["jest-junit", { "outputDirectory": "reports", "outputName": "junit.xml" }]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue