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.

Jest matcher import is breaking webpack projects.

See original GitHub issue

The Issue

This project, or one of its dependencies, has an incorrect import path. This causes the test suite to crash whenever the rxSandbox.create() function is called.

The offending import is here: https://github.com/kwonoj/rx-sandbox/blob/master/src/assert/marbleAssert.ts

Steps to reproduce:

Create a new Angular project. Import rxSandbox and call the create() function.

Error Log

ERROR in ./node_modules/jest-matchers/node_modules/pretty-format/build-es5/plugins/ReactElement.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/typeof' in 'E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\build-es5\plugins'
resolve 'babel-runtime/helpers/typeof' in 'E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\build-es5\plugins'
  Parsed request is a module
  using description file: E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\package.json (relative path: ./build-es5/plugins)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      looking for modules in E:/test/dddd
        using description file: E:\test\dddd\package.json (relative path: .)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: E:\test\dddd\package.json (relative path: ./babel-runtime/helpers/typeof)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\babel-runtime\helpers\typeof doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\babel-runtime\helpers\typeof.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\babel-runtime\helpers\typeof.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\babel-runtime\helpers\typeof.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\babel-runtime\helpers\typeof.js doesn't exist
            as directory
              E:\test\dddd\babel-runtime\helpers\typeof doesn't exist
      E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\build-es5\plugins\node_modules doesn't exist or is not a directory
      E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\build-es5\node_modules doesn't exist or is not a directory
      E:\test\dddd\node_modules\jest-matchers\node_modules\node_modules doesn't exist or is not a directory
      E:\test\dddd\node_modules\node_modules doesn't exist or is not a directory
      E:\test\node_modules doesn't exist or is not a directory
      E:\node_modules doesn't exist or is not a directory
      looking for modules in E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules
        using description file: E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in E:\test\dddd\node_modules\jest-matchers\node_modules
        using description file: E:\test\dddd\node_modules\jest-matchers\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in E:\test\dddd\node_modules
        using description file: E:\test\dddd\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\package.json (relative path: ./node_modules/babel-runtime/helpers/typeof)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: E:\test\dddd\node_modules\jest-matchers\package.json (relative path: ./node_modules/babel-runtime/helpers/typeof)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: E:\test\dddd\package.json (relative path: ./node_modules/babel-runtime/helpers/typeof)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\babel-runtime\helpers\typeof doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\babel-runtime\helpers\typeof.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\babel-runtime\helpers\typeof.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\babel-runtime\helpers\typeof.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.js doesn't exist
            as directory
              E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof doesn't exist
              E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.js doesn't exist
            as directory
              E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof doesn't exist
              E:\test\dddd\node_modules\babel-runtime\helpers\typeof.js doesn't exist
            as directory
              E:\test\dddd\node_modules\babel-runtime\helpers\typeof doesn't exist
[E:\test\dddd\babel-runtime\helpers\typeof]
[E:\test\dddd\babel-runtime\helpers\typeof.ts]
[E:\test\dddd\babel-runtime\helpers\typeof.tsx]
[E:\test\dddd\babel-runtime\helpers\typeof.mjs]
[E:\test\dddd\babel-runtime\helpers\typeof.js]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\build-es5\plugins\node_modules]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\build-es5\node_modules]
[E:\test\dddd\node_modules\jest-matchers\node_modules\node_modules]
[E:\test\dddd\node_modules\node_modules]
[E:\test\node_modules]
[E:\node_modules]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof]
[E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof]
[E:\test\dddd\node_modules\babel-runtime\helpers\typeof]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.ts]
[E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.ts]
[E:\test\dddd\node_modules\babel-runtime\helpers\typeof.ts]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.tsx]
[E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.tsx]
[E:\test\dddd\node_modules\babel-runtime\helpers\typeof.tsx]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.mjs]
[E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.mjs]
[E:\test\dddd\node_modules\babel-runtime\helpers\typeof.mjs]
[E:\test\dddd\node_modules\jest-matchers\node_modules\pretty-format\node_modules\babel-runtime\helpers\typeof.js]
[E:\test\dddd\node_modules\jest-matchers\node_modules\babel-runtime\helpers\typeof.js]
[E:\test\dddd\node_modules\babel-runtime\helpers\typeof.js]
 @ ./node_modules/jest-matchers/node_modules/pretty-format/build-es5/plugins/ReactElement.js 1:128-167
 @ ./node_modules/jest-matchers/node_modules/pretty-format/build-es5/index.js
 @ ./node_modules/jest-matchers/node_modules/jest-matcher-utils/build-es5/index.js
 @ ./node_modules/jest-matchers/build/matchers.js
 @ ./node_modules/rx-sandbox/dist/src/assert/marbleAssert.js
 @ ./node_modules/rx-sandbox/dist/src/index.js
 @ ./src/app/app.component.spec.ts
 @ ./src sync \.spec\.ts$
 @ ./src/test.ts

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kwonojcommented, Nov 2, 2020

published 1.0.4.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Cannot use import statement outside a module ...
When you use ECMAScript Modules in Node (v13.6.0 for me) combined with Jest, the following error occurs: SyntaxError: Cannot use import ...
Read more >
Importing images breaks jest test - Stack Overflow
When you import image files, Jest tries to interpret the binary codes of the images as .js, hence runs into errors.
Read more >
Change: "Jest uses custom config" to "Jest uses webpack" (#5 ...
Currently our Jest config does not use webpack for transpiling. This causes a bit of duplication in configuration between webpack configuration ...
Read more >
Using with webpack - Jest
Jest can be used in projects that use webpack to manage assets, styles, ... We've told Jest to ignore files matching a stylesheet...
Read more >
Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
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