version: 2

jobs:
  build-and-test:
    docker:
      - image: node:8.12
    steps:
      - checkout
      - restore_cache: # special step to restore the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: Build Dependencies
          command: npm install
      - save_cache: # special step to save the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: Run Tests
          command: npm test
workflows:
  version: 2
  build-test:
    jobs:
      - build-and-test