Skip to content

[Bug]: jest.unstable_mockModule does not work with custom dynamic import wrapper #14856

Open

Description

Version

29.7.0

Steps to reproduce

conventional-changelog/commitlint#3850

yarn test-ci

Expected behavior

No error

Actual behavior

 RUNS  @commitlint/load/src/utils/load-plugin.test.ts
/Users/JounQin/Workspaces/GitHub/commitlint/@commitlint/load/src/utils/load-plugin.ts:35
                throw new MissingPluginError(pluginName, message, {
                      ^

MissingPluginError: Failed to load plugin example: Cannot find module 'commitlint-plugin-example' from '@commitlint/load/src/utils/load-plugin.ts'
    at loadPlugin (/Users/JounQin/Workspaces/GitHub/commitlint/@commitlint/load/src/utils/load-plugin.ts:35:23) {
  ['__proto__']: [Function: Error] {
    stackTraceLimit: 100,
    prepareStackTrace: [Function: prepareStackTrace]
  },
  messageTemplate: 'plugin-missing',
  messageData: {
    pluginName: 'commitlint-plugin-example',
    commitlintPath: '/Users/JounQin/Workspaces/GitHub/commitlint/@commitlint/load'
  }
}

Additional context

I've also tried 30.0.0-alpha.2 locally but still failed.

Environment

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 18.19.0 - ~/Library/Caches/fnm_multishells/43242_1705330700273/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/43242_1705330700273/bin/yarn
    npm: 10.2.3 - ~/Library/Caches/fnm_multishells/43242_1705330700273/bin/npm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions