Node js Sequential Workflow example is not working

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

I’ve not used workflows, but I can’t see how that has ever worked - most odd. You need to persist the folder(s) between jobs, which is detailed here.

If that fixes it, would you raise a documentation bug report? It is possible that I (we) have misunderstood the point of that example, of course, but it’s worth raising, IMO.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.