version: 2
jobs:
  test:
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - run:
          name: update npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
      - run:
          name: npm install 
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: lint
          command: npm run lint
      - run:
          name: test
          command: npm test
      - run:
          name: upload coverage
          command: npm run report-coverage
      - store_artifacts:
          path: ./artifacts
          prefix: artifacts
      - store_test_results:
          path: ./artifacts/test-reports
workflows:
  version: 2
  test:
    jobs:
      - test
