Jest Tests on CI Pipeline

MD
S
Markdown

Automated Jest test execution guide for continuous integration pipelines. Ensures code quality and catches regressions before deployment.

  1. Dockerfile
RUN npm run server-w-test

EXPOSE 3600
CMD [ "pm2-runtime", "pm2.json" ]
  1. Package.json "server-w-test": "NODE_ENV=tests concurrently --kill-others --success first -p "[{name}]" -n "TypeScript,Node" -c "yellow.bold,cyan.bold,green.bold" "npm run serve-ci" "npm run test-ci" ", "test-ci": "jest --runInBand -u --watchAll=false --detectOpenHandles", "serve-ci": "node ./dist/app.js",

  2. Jest.config.json

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "esnext",
    "skipLibCheck": true,
    "noImplicitAny": false,
    "resolveJsonModule": true,
    "suppressImplicitAnyIndexErrors": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": ".",
    "experimentalDecorators": true
  }
}

Created on 8/20/2021