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

new module transformer on 1.2.206 broke * imports + spyOn combination #7652

Closed
davidmatas opened this issue Jul 12, 2023 · 2 comments
Closed
Labels

Comments

@davidmatas
Copy link

davidmatas commented Jul 12, 2023

Describe the bug

Version 1.2.206 introduce some bug for import * as declaration

Prior to that version code like this worked without problems:

Implementation file

export const useGetRequest = () => {}...

Test file

import * as hook from '../../useGetRequest/useGetRequest';

jest.spyOn(hook, 'useGetRequest')

Now when I executed the test it fails with the following error:

    TypeError: Cannot redefine property: useGetRequest
        at Function.defineProperty (<anonymous>)

      15 |   constructor() {
      16 |     this.jestSpy = jest.fn();
    > 17 |     this.jestMock = jest.spyOn(hook, 'useGetRequest')

Input code

No response

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": false,
      "dynamicImport": true
    },
    "target": "es2015"
  },
  "sourceMaps": true
}

Playground link

No response

Expected behavior

I guess it should work like in the previous version. It seems TS and Babel already had this problem. Stackoverflow thread

Actual behavior

No response

Version

1.2.206 and later

Additional context

No response

@kwonoj
Copy link
Member

kwonoj commented Jul 12, 2023

#7435

@kwonoj kwonoj closed this as completed Jul 12, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Aug 12, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants