question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with a cache and the testEnvironment variable.

See original GitHub issue

🐛 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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:11

github_iconTop GitHub Comments

4reactions
Drischdaancommented, Aug 15, 2020

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

EDIT: Fixed it by using jest v25.1.0

3reactions
chbrocommented, Sep 27, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel 5.8 .env.testing file is not working
The testing environment variables can be configured in the phpunit.xml file, but make sure to clear your configuration cache using the config: ...
Read more >
Testing and Environment Variables
Another common way to test environment variables is by overriding them ... we must always cache and reassign state every time we modify...
Read more >
Solving common problems
When using a shared cache, these problems even cross machine boundaries. ... Gradle does not track changes in environment variables for tasks.
Read more >
Creating and editing an environment cache | Apigee Edge
You can create multiple cache resources in each environment. When you're configuring a caching policy, you specify whether the policy should use the...
Read more >
Configuring Vitest
For example, define to define global variables, or resolve.alias to ... This might be helpful, if a dependency has the wrong ESM file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found