A simple example of a pipeline for NodeJS project with npm, nyc & mocha.
In the following example we’re building and testing a Node.js project using
node docker image.
There are three stages of the pipeline:
- deps — installs all the required dependencies (
- test — runs unit tests and shows the total code coverage
- coverage — ensures that the total coverage is not below 90%
image: node:13 stages: - deps - test - coverage install dependencies: stage: deps commands: - npm install unit tests: stage: test commands: - node_modules/.bin/nyc --reporter=text node_modules/.bin/mocha coverage: stage: coverage commands: # fail if the total coverage is below 90% - node_modules/.bin/nyc --check-coverage --lines 90
Last modified September 17, 2020