Unable to test a project using pirates
See original GitHub issueDo 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:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
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.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.