Skip to content

[Bug]: hybrid module warning cluttering tests output #5013

@toomuchdesign

Description

@toomuchdesign

Version

29.4.1

Steps to reproduce

This commit introduced a tsconfig properties check issuing the following warning when tsconfig.compilerOptions.isolatedModules is not true and tsconfig.compilerOptions.module is node16 or nodenext.

ts-jest[ts-compiler] (WARN) Using hybrid module kind (Node16/18/Next) is only supported in "isolatedModules: true". Please set "isolatedModules: true" in your tsconfig.json.

As far as I know this is a widely common setup and it seems to be fully supported by ts-jest.

Since when the warning has been introduced, all my commonJS tests have turned into a wall of warnings.

See screenshot Image

I initially tried to enable isolatedModules as suggested by the warning but it turned out that isolatedModules handling is currently flawed in ts-jest and caused the library to skip type checking at test execution time:

I even tried to suppress the specific log entry but since ts-jest uses a logger library it turned out to be overkill.

I open this issue to try and find a solution to make ts-jest usable again on CommonJS project using type check at test execution time. Here are a few possible steps:

  1. Remove the log and the check. Why was it introduced? I couldn't find any info in the commit message
  2. Find a way to filter warnings output
  3. Do not disable type check with isolatedModules is true (see PR)

I understand changing isolatedModules behaviour could be an effort that this library might not be able to afford short-term. What about the 2 other solutions?

Would point 1 a quick painless solution implementable short term?

Thank you for your attention, happy to land hand if the case.

Expected behavior

Actual behavior

Debug log

Additional context

Environment

-

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions