Skip to content

createRequire support & a way to access the mocked require #265

Description

@PaperStrike

The package I want to mock uses createRequire to require, which proxyquire doesn't proxy yet. To workaround, I tried:

proxyquire('./example', {
  module: {
    createRequire: (filename) => Object.assign((id) => require(id), {
      // ...some other stuff like `resolve`
    }),
    '@global': true,
  },
  // ... stubs I use
});

But then I found the require above can't be the mocked one. I wonder if you can support createRequire and give us a way to access the mocked require (so that we can mock createRequire to return a require with our own properties).

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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