Skip to content

Documentation should mention how to handle default-export imports #280

Description

@jtarvainen

The documentation should mention how to handle default-export imports. For example, in the following case:

  1. We want to test the default export main from main.ts,
  2. main.ts imports the default export importedFunction from importedFunction.ts, and
  3. We want to stub importedFunction with importedFunctionStub;

then we need to do this:

const { default: main } = proxyquire<{ default: typeof main }>(
    'path/to/main', {
        'path/to/importedFunction': { default: importedFunctionStub },
    }
);

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