Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SWC Jest] Jest Mocking issues with built-in modules with / in import like dns/promises #8906

Closed
iamchathu opened this issue Apr 30, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@iamchathu
Copy link

iamchathu commented Apr 30, 2024

Describe the bug

The mocking doesn't work with built-in modules when there is / in the import. The tests works with ts-jest without issues.

Input code

https://stackblitz.com/edit/swc-jest-bug?file=src%2Findex.spec.ts

Config

{
  "$schema": "https://json.schemastore.org/swcrc",
  "sourceMaps": true,
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "dynamicImport": true
    },
    "transform": {
      "legacyDecorator": true,
      "decoratorMetadata": true
    },
    "baseUrl": "./"
  },
  "minify": false
}

Playground link (or link to the minimal reproduction)

https://stackblitz.com/edit/swc-jest-bug?file=src%2Findex.spec.ts

SWC Info output

Operating System:
Platform: linux
Arch: x64
Machine Type: undefined
Version: Ubuntu 20.04.0 LTS Tue Apr 30 2024 11:53:11 GMT+0200 (Central European Summer Time)
CPU: (4 cores)
Models: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz

Binaries:
    Node: 18.18.0
    npm: 10.2.3
    Yarn: 1.22.19
    pnpm: 8.15.6

Relevant Packages:
    @swc/core: 1.4.17
    @swc/helpers: N/A
    @swc/types: N/A
    typescript: 5.4.5

SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

Use manual mocks and test should pass

Actual behavior

The manual mock is ignored

Version

1.4.17

Additional context

It's was working on

"@swc/core": "^1.3.105",
"@swc/jest": "^0.2.31",

and broken after

"@swc/core": "^1.4.17",
"@swc/jest": "^0.2.36",
@kdy1 kdy1 self-assigned this May 6, 2024
@kdy1 kdy1 added this to the Planned milestone May 6, 2024
@kdy1
Copy link
Member

kdy1 commented May 7, 2024

'ts-jest' is wrong here.#7435

jest.mock of ESM fails / Cannot modify ES modules.

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.5.5 May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants