Skip to content

TypeError: Cannot read property 'fileName' of undefined #21

@kkm000

Description

@kkm000

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:

const allDiagnostics = ts
.getPreEmitDiagnostics(program)
.concat(emitResult.diagnostics)
.filter(diagnostic => diagnostic.file.fileName === testPath);

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions