Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsdx test errors: Cannot find module 'babel-jest' #1110

Open
stephencweiss opened this issue Feb 7, 2022 · 2 comments
Open

tsdx test errors: Cannot find module 'babel-jest' #1110

stephencweiss opened this issue Feb 7, 2022 · 2 comments
Labels
problem: stale Issue has not been responded to in some time

Comments

@stephencweiss
Copy link

stephencweiss commented Feb 7, 2022

Current Behavior

When I run yarn test my code it now breaks.

Expected behavior

I'd expect the test report to run successfully.

Suggested solution(s)

A clearer understanding of how babel-jest needs to be configured to avoid this problem -- it appears that tsdx can't find the module babel-jest... but it's listed as a dependency due tsdx when I run yarn why.

Additional context

The key point here is that my main branch works just fine, a feature branch breaks on this and it's unclear to me why. The only changes to dependencies were:

// package.json
+       "@rollup/plugin-url": "^6.1.0",
+      "@svgr/rollup": "^6.2.1",

No changes to jest.config

Related question: #688

yarn test
yarn run v1.22.4
$ tsdx test --passWithNoTests --coverage
/Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/index.js:385
        throw err;
        ^

Error: Cannot find module 'babel-jest'
Require stack:
- /Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/createJestConfig.js
- /Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.resolve (internal/modules/cjs/helpers.js:80:19)
    at Object.createJestConfig (/Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/createJestConfig.js:7:35)
    at /Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/index.js:388:73
    at Sade.parse (/Users/stephen.weiss/code/olo/expo-web-ui/node_modules/sade/lib/index.js:189:56)
    at Object.<anonymous> (/Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/index.js:462:6)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/createJestConfig.js',
    '/Users/stephen.weiss/code/olo/expo-web-ui/node_modules/tsdx/dist/index.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn why babel-jest -R
yarn why v1.22.4
[1/4] 🤔  Why do we have the module "babel-jest"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "babel-jest@25.5.1"
info Reasons this module exists
   - "tsdx#jest#@jest#core#jest-config" depends on it
   - Hoisted from "tsdx#jest#@jest#core#jest-config#babel-jest"
✨  Done in 0.74s.

Your environment

%  npx envinfo --system OS --browsers --binaries --npmPackages tsdx,typescript --npmGlobalPackages tsdx,typescript
npx: installed 1 in 1.211s

  System:
    OS: macOS 11.6.2
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 1.11 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.22.3 - ~/.volta/tools/image/node/12.22.3/bin/node
    Yarn: 1.22.4 - ~/.volta/tools/image/yarn/1.22.4/bin/yarn
    npm: 6.14.13 - ~/.volta/tools/image/node/12.22.3/bin/npm
  Browsers:
    Brave Browser: 98.1.35.100
    Chrome: 97.0.4692.99
    Firefox: 91.0.2
    Safari: 14.1.2
    Safari Technology Preview: 15.4
  npmPackages:
    tsdx: ^0.14.1 => 0.14.1
    typescript: ^4.2.3 => 4.2.3
@aladdin-add
Copy link

sometimes yarn did not dedupe babel-jest, just try:

  • yarn dedupe (yarn >=2.x)
  • npx yarn-deduplicate (yarn v1)

@stephencweiss
Copy link
Author

Thanks @aladdin-add! I'll give it a shot!

@agilgur5 agilgur5 added the problem: stale Issue has not been responded to in some time label Apr 11, 2022
@agilgur5 agilgur5 changed the title tsdx test breaking on babel-jest tsdx test errors: Cannot find module 'babel-jest' Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem: stale Issue has not been responded to in some time
Projects
None yet
Development

No branches or pull requests

3 participants