version: 2.1
jobs:
  build:
    docker:
      - image: node:12
      - image: mongo:4.2
    steps:
      - checkout
      - run:
          name: update-npm
          command: 'npm install -g npm@6'
      - restore_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
      - run:
          name: install-npm-wee
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: update host file
          command: |
            echo 127.0.0.1 dashboard.test site.test site2.test | tee -a /etc/hosts
            cat /etc/hosts
      - run:
          name: test
          command: npm test
