jest-runner-tsc icon indicating copy to clipboard operation
jest-runner-tsc copied to clipboard

TypeError: Cannot read property 'fileName' of undefined

Open kkm000 opened this issue 5 years ago • 4 comments

I attempted to use jest-runner-tsc for the first time, and am getting the exception when trying to run the test:

  ● Test suite failed to run

    TypeError: Cannot read property 'fileName' of undefined

      at node_modules/jest-runner-tsc/dist/runTsc.js:79:28
          at Array.filter (<anonymous>)
      at runTsc (node_modules/jest-runner-tsc/dist/runTsc.js:77:106)

The error happens here: https://github.com/azz/jest-runner-tsc/blob/f5100dda54be279a923641a3e081829aadac020a/src/runTsc.js#L62-L65

and the diagnostic at this point is:

{
  file: undefined,
  start: undefined,
  length: undefined,
  messageText:
   'Option \'--incremental\' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified.',
  category: 1,
  code: 5074,
  reportsUnnecessary: undefined,
  reportsDeprecated: undefined
}

Versions:
node.js v10.18.1
jest v.26.4.2
typescript v4.0.2

LMK please if I should dig any deeper.

kkm000 avatar Aug 31 '20 15:08 kkm000

The same issue here.

prokopsimek avatar Oct 27 '20 06:10 prokopsimek

My diagnostic was

{
  file: undefined,
  start: undefined,
  length: undefined,
  code: 6059,
  category: 1,
  messageText: {
    messageText: "File '/.../test/exchange.test.ts' is not under 'rootDir' '/.../src'. 'rootDir' is expected to contain all source files.",
    category: 1,
    code: 6059,
    next: [ [Object] ]
  },
  relatedInformation: undefined
}

Solved by moving test directory inside src dir

tony-ist avatar Apr 14 '21 19:04 tony-ist

I fixed this by adding

"tsBuildInfoFile": ".tsbuildinfo"

to my tsconfig file.

patrick-mcdougle avatar Nov 09 '21 16:11 patrick-mcdougle

I had this issue as well when specifying "incremental": true in tsconfig.json. Removing incremental builds solves the issue.

matt-oplo avatar Mar 28 '22 08:03 matt-oplo