Jest: Problem with a cache and the testEnvironment variable.

Created on 31 Jul 2020  ·  9Comments  ·  Source: facebook/jest

🐛 Bug Report


When I execute tests I got:

 FAIL  src/test/javascript/app/actions.spec.js
  ● Test suite failed to run

    ENOENT: no such file or directory, mkdir '/tmp/jest_rs/jest-transform-cache-951c940de58b523ede4c7a74cd57e1d8-afca7609b727bae58e6d966e4f38887d/2e'

      at createDirectory (node_modules/jest-runtime/node_modules/jest-util/build/createDirectory.js:68:10)

No matter what I do(clear cache, run with --no-cache) then the result is the same. But when I create this directory by

 mkdir -p /tmp/jest_rs/jest-transform-cache-951c940de58b523ede4c7a74cd57e1d8-afca7609b727bae58e6d966e4f38887d/2e

then an exception is different:

 FAIL  src/test/javascript/app/modeler/actions.spec.js
  ● Test suite failed to run

    The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.
    Consider using the "jsdom" test environment.

    ReferenceError: window is not defined

      1 | import React from 'react';
      2 | 
    > 3 | window.React = React;

This is from mt setupTests.js that I have in the setupFilesAfterEnv.
testEnvironment is set to jsdom. When I check that by --show-config I have:

"testEnvironment": "/node_modules/jest-environment-jsdom/build/index.js",

envinfo

  System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 10.10.0 - /usr/bin/node
    Yarn: 1.10.1 - ~/projects/bpm-micro/gateway/node_modules/.bin/yarn
    npm: 5.1.0 - ~/projects/bpm-micro/gateway/node_modules/.bin/npm
  npmPackages:
    jest: ^26.0.1 => 26.1.0
Bug Report Needs Repro Needs Triage

Most helpful comment

Same problem but on Windows 10. I have node version 10.10.0

EDIT:
Fixed it by using jest v25.1.0

All 9 comments

@mkawczynski07
Marek, try to update node. I updated it to 6.14.6 from 6.4.1 and it looks it was the case.

Same problem but on Windows 10. I have node version 10.10.0

EDIT:
Fixed it by using jest v25.1.0

@pawel-sz Didn't help.

same here on mac, downgrading jest-util to ^25.0.0 works for me

same for me too, still having an issue on jest-util 26.0.4

Downgrading jest to ^25.0.0 fixed the issue for me too :) Node 10.9.0, Ubuntu 20.04

Node Version <10.12 doesn’t support recursive options from fs.mkdir and fs.mkdirSync.

https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V10.md#2018-10-10-version-10120-current-targos

Was this page helpful?
0 / 5 - 0 ratings