Skip to content

Tests doesn't pass when allowJS is set to true #2350

@ilankhirin

Description

@ilankhirin

🐛 Bug Report

I'm writing a npm package in Typescript and in this project I use some third party library that is written in js. Since I need this js file to be in the build folder in the end of build process(and also for an easier development process), I set "allowJs" to be true in my tsconfig.json.
I use jest for my tests and my preset is ts-jest. When I run my tests I get the following error:

TypeError: tests\test123.test.ts: Emit skipped for language service
      at compileFn (node_modules/ts-jest/dist/compiler/language-service.js:269:23)

But if I change allowJS to false, everything works fine.
I thought the problem might be in the third party library or in my project but I was able to reproduce the error on a clean project here

To Reproduce

Steps to reproduce the behavior:
git clone https://github.com/ilankhirin/ts-jest-issue.git
*npm i
*npm run test
You should get an error

*Change allowJS to false in tsconfig.json
*Re-run "npm run test"
No problem

Expected behavior

I expect the tests to pass with allowJS set to true.

Link to repo (highly encouraged)

https://github.com/ilankhirin/ts-jest-issue

Debug log:

# content of ts-jest.log :

https://github.com/ilankhirin/ts-jest-issue/blob/main/ts-jest.log

envinfo

System:
    OS: Windows 10
    Node version: 12.18.4

Npm packages:
    jest: 26.6.3
    ts-jest: 26.5.1
    typescript: 4.1.5
    babel(optional): no babel

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions