Unexpected behavior of Gitlab CI catche paths

I ran into unexpected behavior of gitlab CI cache. I can’t understand why build job work’s without adding - node_modules/ to its cache paths, since script gitlab-build depends on it.

For example if node_modules/ are not present under test job cache paths, app fails. I think failing in this scenario is expected but can’t really understand why CI doesn’t fail if node_modules/ aren’t present in build job cache paths.

    stages:
      - test
      - build

    lint:
      stage: test
      before_script:
        - npm install
      script: "./scripts/gitlab-lint"
      cache:
        untracked: true
        key: "calfe"
        paths:
          - node_modules/

    test:
      stage: test
      script: "./scripts/gitlab-test"
      cache:
        key: "calfe"
        paths:
          - node_modules/
        policy: pull

    build:
      stage: build
      script: "./scripts/gitlab-build"
      cache:
        key: "calfe"
        paths:
          - build/