Skip to content

jest.mock of ESM should fail, and it's correct #5205

Closed
@kdy1

Description

@kdy1

This is not an issue, because the input was already wrong.

If you really want to workaround this, see #5151 (comment)
Note that this is not an official one, and it will break frequently.


jest not working with ESM is not an issue of swc. See jestjs/jest#9430

common js vs ESM behavior

Technically this can be workarounded by SWC by compiling in a wrong way.

But ESM is an established standard, and swc follows the specification. If you use ESM as input, swc will compile the code to behave in a way defined by the specification.

You may claim the official typescript compiler does not follow specification if module type is common js, but it's a bug of tsc. If you want behavior of common js, you can write a common js module instead.


Discussions

Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions