Skip to content

Can't require files with mocked filesystem #130

@xavdid

Description

@xavdid

Hey there!

So I'm having sort of a weird problem. I'm testing a function that reads from a file and does stuff with the contents. I'm using mock-fs and everything is great. However, one of the modules I'm using changed their code so that there are require statements in functions that get called during the test (in my case, an HTTP request). When the mock is active, require('./blah') fails because unless I've mirrored that file (which lives > 3 levels down in node_modules), it's not found. More specific examples are here.

Is it currently possible (or possible to add) an option so that the fs is mocked as normal, but all calls to require are untouched?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions