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.

Unable to test a project using pirates

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When running jest on a project that uses pirates to customize the loading of modules, jest interferes with the operation of pirates, seeming to prevent it from working correctly. For example, when trying to load code written using ES modules using babel to transpile them, it works just fine when running the tests with mocha.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

This isn’t a minimal example, but cloning https://github.com/square/babel-codemod and checking out the jest branch, running yarn install and yarn test will illustrate the problem.

What is the expected behavior?

Jest should not interfere with other systems–like pirates–that hook into module loading.

Please provide your exact Jest configuration

module.exports = {
  automock: false,
  transform: {
    '^.+\\.tsx?$': 'ts-jest'
  },
  testRegex: '(/__tests__/.*|(\\.|/)(test|spec)|.*(Test|Spec))\\.(jsx?|tsx?)$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};

Run npx envinfo --preset jest in your project directory and paste the results here

  System:
    OS: macOS High Sierra 10.13.3
    CPU: x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  Binaries:
    Node: 9.11.1 - /usr/local/bin/node
    Yarn: 1.6.0 - /usr/local/bin/yarn
    npm: 5.6.0 - /usr/local/bin/npm
  npmPackages:
    @types/jest: ^22.2.3 => 22.2.3
    jest: ^22.4.3 => 22.4.3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
eventualbuddhacommented, Apr 19, 2018

This is pretty much the response I expected. I figured I’d file this as a vote in favor of a more standard config. I really like Jest’s workflow, but things like this worry me.

Perhaps a mode that uses the native require but doesn’t support mocking would work? I don’t know if the mocking is the only reason that jest has its own require system.

0reactions
github-actions[bot]commented, Apr 29, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MACKLEMORE & RYAN LEWIS - CAN'T HOLD US ... - YouTube
Macklemore & Ryan Lewis present the official music video for Can't Hold Us feat. Ray Dalton. Can't Hold Us on iTunes: ...
Read more >
Why Pirates Producer Says "You Can't" Kill Johnny Depp's Role
Pirates of the Caribbean producer Jerry Bruckheimer said he would “love” to have Johnny Depp in another of the franchise's films.
Read more >
Unable to come to ECU to watch the... - Pitt Pirates Robotics ...
Unable to come to ECU to watch the action? Watch the livestream on Twitch! https://m.twitch.tv/firstinspires27.
Read more >
Why does this test fail? - The Testing Pirate
The failing step, that jenkins shows in the test report, tells that there is something wrong since that day. The origin of the...
Read more >
Xcode 10 framework test: unable to… | Apple Developer Forums
It would be helpful if you tried extracting the code from your app into a small test project and included that in the...
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