I followed the example here: https://circleci.com/docs/2.0/sample-config/#sample-configuration-with-sequential-workflow
I updated it to:
version: 2
jobs:
  build:
    working_directory: ~/mern-starter
    # The primary container is an instance of the first image listed. The job's commands run in this container.
    docker:
      - image: circleci/node:10
    steps:
      - checkout
      - run:
          name: Update npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install npm wee
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules
  test:
    docker:
      - image: circleci/node:10
    steps:
      - checkout
      - run:
          name: Test
          command: npm run test:unit
workflows:
  version: 2
  build_and_test:
    jobs:
      - build
      - test:
          requires:
            - build
(just upgraded node version to 10, removed mongo and store_artifacts)
The node_modules folder is not kept between build and test jobs and so the npm test command fails.
Is the example outdated?
If so, what is the official way to make it work?
If not, how I can use a separate job for build and test?
Thanks