Skip to content

Instantly share code, notes, and snippets.

Last active February 14, 2023 18:49
What would you like to do?
From Tech with Love

From Tech with Love

Some Coding Principles



Dockerfile & node

If you use npm to start your app, you will lose some important intels like complete error messages relative to node. To avoid this, you should set a CMD at the end of your Dockerfile:

FROM node:alpine

CMD ["node", "index.js"]

Coverage on Integration tests

In Gitlab-ci

  stage: tests
    - npm ci
    # Run service wrapped with nyc as a background task
    - NODE_ENV=ci npx nyc node index.js &
    # Store node's pid
    - echo $! > pid
    # Wait for our service to boot
    - sleep 3
    # Run tests and kill service if test fail
    - NODE_ENV=ci npm test || ( ( kill -SIGINT `cat pid` || true ) && rm pid && false )
    # Kill service
    - ( kill -SIGINT `cat pid` || true ) && rm pid
    # Wait one second to let the nyc wrapper generate coverage result
    - sleep 1
      - coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment