CI for Node.js
Build, lint, and test a Node.js web application using npm, ESLint, Jest, and Cypress.
Use template →1steps:
2 - label: ":npm: Install dependencies"
3 key: "deps"
4 command: npm install
5 plugins:
6 - artifacts#v1.9.3:
7 upload: "node_modules"
8 compressed: node_modules.tgz
9 - docker#v5.9.0:
10 image: "node:20.11"
11
12 - label: ":eslint: Run ESLint"
13 command: "npx eslint"
14 depends_on: "deps"
15 plugins:
16 - artifacts#v1.9.3:
17 download: "node_modules"
18 compressed: node_modules.tgz
19 - docker#v5.9.0:
20 image: "node:20.11"
21
22 - label: ":jest: Run unit tests"
23 depends_on: "deps"
24 command: "npx jest"
25 plugins:
26 - artifacts#v1.9.3:
27 download: "node_modules"
28 compressed: node_modules.tgz
29 - docker#v5.9.0:
30 image: "node:20.11"
31
32 - label: ":cypress: Run cypress tests"
33 depends_on: "deps"
34 commands:
35 - npm install
36 - npm start & npx --yes wait-on http://localhost:8000
37 - npx cypress run
38 plugins:
39 - docker#v5.9.0:
40 image: cypress/browsers:node18.12.0-chrome106-ff106
41 options: --user 1001
42 volumes:
43 - /workdir/node_modules
- Languages
- JavaScript
- Use cases
- Continuous integration, Web application
- Platforms
- Docker
CI for Node.js
Build, lint, and test a Node.js web application using npm, ESLint, Jest, and Cypress.
Use template →CI for Node.js
This template gives you a continuous integration (CI) pipeline that builds, lints, and end-to-end tests a Node.js application.
At a glance:
- For Node.js apps
- Uses npm
- Requires Docker
- Lints code with ESLint
- Runs Jest unit tests
- Runs Cypress integration tests
How it works
This template:
- Installs Node.js dependencies using npm, caching the result.
- Performs static analysis on the codebase with ESLint.
- Runs Jest unit tests.
- Starts the web app using
npm start
on port8000
, then runs any Cypress tests using their official Docker image. It useswait-on
to verify the app is ready for testing.
All steps run in serial, with each depending on the previous step to complete before starting. The runtime environment uses a Docker image with the latest version of Node.
Next steps
After you select Use template, you’ll:
- Connect the Git repository for your Node.js app.
- Check the commands match your scripts in
package.json
. - Configure the compute—run locally, on-premises, or in the cloud.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.