Skip to content

Instantly share code, notes, and snippets.

@heiso
Last active February 14, 2023 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heiso/67240fdeb32129933e1b1cb2dc6ec2da to your computer and use it in GitHub Desktop.
Save heiso/67240fdeb32129933e1b1cb2dc6ec2da to your computer and use it in GitHub Desktop.
From Tech with Love

From Tech with Love

Some Coding Principles

Misc

Graphql

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

test_integration:
  stage: tests
  script:
    - 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
  artifacts:
    paths:
      - coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment