Skip to content

files with empty content causes test failed #2625

@SkeLLLa

Description

@SkeLLLa

💥 Regression Report

Last working version

Worked up to version: 26.X.X

Stopped working in version: 27.0.0

To Reproduce

Steps to reproduce the behavior:

  1. Create global-setup.ts script which may do nothing
  2. Add it to jest.config alongside ts-jest transformer.
module.exports = {
  globals: {
    'ts-jest': {
      babelConfig: false,
      tsconfig: 'tsconfig.json',
    },
  },
  globalSetup: './__test__/jest/global-setup.ts',
  transform: {
    '^.+\\.(ts|tsx)$': ['ts-jest', {}],
  },
}

Expected behavior

ts-jest should transform global-setup and run it. Instead of it throws following error.

Error: Jest: Got error running globalSetup - /<project>/__test__/jest/global-setup.ts, reason: Unable to process '/<project>/__test__/jest/global-setup.ts', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform /<project>/__test__/jest/global-setup.ts
    at TsCompiler.getCompiledOutput (/<project>/node_modules/ts-jest/dist/compiler/ts-compiler.js:131:27)
    at TsJestCompiler.getCompiledOutput (/<project>/node_modules/ts-jest/dist/compiler/ts-jest-compiler.js:13:39)
    at TsJestTransformer.process (/<project>/node_modules/ts-jest/dist/ts-jest-transformer.js:146:37)
    at ScriptTransformer.transformSource (/<project>/node_modules/@jest/core/node_modules/@jest/transform/build/ScriptTransformer.js:612:31)
    at revertHook.exts (/<project>/node_modules/@jest/core/node_modules/@jest/transform/build/ScriptTransformer.js:864:18)
    at Module._compile (/<project>/node_modules/pirates/lib/index.js:93:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.newLoader [as .ts] (/<project>/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

In tsconfig.json:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "composite": false,
    "incremental": false,
    "rootDir": "./",
    "outDir": "./dist/",
    "target": "ES2019"
  },
  "include": ["src", "*.ts", "**/__test__/*"],
  "exclude": ["**/__mocks__/*"],
  "files": ["./__test__/jest/test-global-types.d.ts"]
}

envinfo

System:
    OS: linux generic

Npm packages:
    jest:27.0.1
    ts-jest:27.0.0
    typescript:3.8.X
    babel(optional): none

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions