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

when use requireDir with Jest,require.extensions is empty #66

Open
i5ting opened this issue Apr 21, 2021 · 1 comment
Open

when use requireDir with Jest,require.extensions is empty #66

i5ting opened this issue Apr 21, 2021 · 1 comment

Comments

@i5ting
Copy link

i5ting commented Apr 21, 2021

https://github.com/aseemk/requireDir/blob/master/index.js#L50

const isJestEnviroment = process.env.JEST_WORKER_ID !== undefined

if (isJestEnviroment) extensions = ['.js', '.json','.mjs']
@rhenandias
Copy link

Apparently, there is a bug envolving dependencies when Jest is used with requireDir, check this thread, this comment in specific, recomends switching requireDir package for require-directory package.

The module require-directory works just fine for me along side Jest.

For me, what would be writed as:
const routesDefinition = requireDir("./routes");

was replaced by:
const routesDefinition = requireDirectory(module, "./routes");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants