Sample Configuration with Sequential Workflow is still wrong

I’m trying to install dependencies and build my app first, save the cache then run all tests in parellel after build is completed.

Based on this from the docs: https://circleci.com/docs/2.0/sample-config/#sample-configuration-with-sequential-workflow

I’ve been trying to get this to work but the node modules or output from my yarn build command are not present.

and this now closed issue: Node js Sequential Workflow example is not working

Can the docs be updated to reflect the required persist_to_workspace option for this to work?

My config for reference:

jobs:
  build:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - restore_cache:
          keys:
            - v2-dependencies-{{ checksum "package.json" }}
      - run:
          command: 'yarn install'
          name: 'Install dependencies'
      - run:
          command: 'yarn run build:app'
          name: 'Build app'
      - save_cache:
          key: v2-dependencies-{{ checksum "package.json" }}
          paths:
            - node_modules
            - public/
  lighthouse:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - run:
          command: npm run test:lighthouse
          name: Lighthouse
  lint:
    docker:
      - image: circleci/node:10
    steps:
      - checkout
      - run: 'yarn lint'
  snapshots:
    docker:
      - image: circleci/node:10
    steps:
      - checkout
      - run:
          command: npm run test:snapshots
          name: Snapshots
  testcafe:
    docker:
      - image: circleci/node:10-browsers
    steps:
      - checkout
      - run:
          command: npm run test:e2e
          name: Testcafe
      - store_artifacts:
          path: ~/artifacts/screenshots
version: 2
workflows:
  build_and_test:
    jobs:
      - build
      - lint:
          requires: 
            - build
      - lighthouse:
          requires: 
            - build
      - snapshots:
          requires: 
            - build
      - testcafe:
          requires: 
            - build
  version: 2

I’ve updated my config to use the persist to workspace functionality.

I’m not using the cache anymore, it seems I probably should though? Would restoring from cache then persisting into the workspace be the best bet here?

references:
  attach_workspace: &attach_workspace
    attach_workspace:
      at: ~/app

defaults: &defaults
  working_directory: ~/app
  docker:
      - image: circleci/node:10-browsers

jobs:
  build:
    <<: *defaults
    steps:
      - checkout
      - run:
          command: 'yarn install'
          name: 'Install dependencies'
      - run:
          command: 'yarn run build:app'
          name: 'Build app'
      - persist_to_workspace:
          root: ~/app
          paths:
            - .cache
            - public
            - node_modules
  lighthouse:
    <<: *defaults
    steps:
      - checkout
      - *attach_workspace
      - run:
          command: npm run test:lighthouse
          name: Lighthouse
  lint:
    <<: *defaults
    steps:
      - checkout
      - *attach_workspace
      - run: 'yarn lint'
  snapshots:
    <<: *defaults
    steps:
      - checkout
      - *attach_workspace
      - run:
          command: npm run test:snapshots
          name: Snapshots
  testcafe:
    <<: *defaults
    steps:
      - checkout
      - *attach_workspace
      - run:
          command: npm run test:e2e
          name: Testcafe
      - store_artifacts:
          path: ~/artifacts/screenshots
version: 2
workflows:
  build_and_test:
    jobs:
      - build
      - lint:
          requires: 
            - build
      - lighthouse:
          requires: 
            - build
      - snapshots:
          requires: 
            - build
      - testcafe:
          requires: 
            - build
  version: 2