Skip to content

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

@jtarvainen

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 },
    }
);

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