Skip to content

Jest requires symlinked files twice #3830

@tmeasday

Description

@tmeasday

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

Bug

What is the current behavior?

When requiring a file via a symlink that has already been required directly, Jest executes the file again. This is in contrast to node, which resolves the symlink's path absolutely and thus reuses the original require.

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.

Reproduction: https://github.com/tmeasday/jest-symlink-repro

Install, then notice the difference between node index.js and npm test.

What is the expected behavior?

I would expect Jest to behave the same as node here.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Tested with jest@20.0.4, node@8.1.0, npm@5.0.3 on OSX 10.12.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions