Ts-jest: Troubles using it with TS3 and composite project

Created on 8 Aug 2018  ·  11Comments  ·  Source: kulshekhar/ts-jest

Issue :

I'm unable to use it with TypeScript 3.0 and composite project

Expected behavior :

I expect the tests to work

Output from debug log :

_I didn't get the debug.txt_, but here's the test output.

a) with enableTsDiagnostics: true

 FAIL  test/testing.test.ts
  ● Test suite failed to run

    error TS6304: Composite projects may not disable declaration emit.

      at Object.runTsDiagnostics [as default] (../../node_modules/ts-jest/src/utils/run-ts-diagnostics.ts:16:11)
      at Object.preprocess [as process] (../../node_modules/ts-jest/src/preprocess.ts:46:21)

Test Suites: 1 failed, 1 total

b) with enableTsDiagnostics: false

 FAIL  test/testing.test.ts
  ● Test suite failed to run

    Debug Failure. Expected "use strict";
    describe('Testing a test', function () {
        it('should be true', function () {
            expect(true).toBeTruthy();
        });
    });
    //# sourceMappingURL=testing.test.js.map === undefined. Unexpected multiple outputs, file: /Users/emirotin/work/learn-a/packages/pkg2/test/testing.test.d.ts

      at Object.assertEqual (../../node_modules/typescript/lib/typescript.js:1389:17)
      at Object.writeFile (../../node_modules/typescript/lib/typescript.js:100504:30)
      at Object.__assign.writeFile (../../node_modules/typescript/lib/typescript.js:83117:596)
      at Object.writeFile (../../node_modules/typescript/lib/typescript.js:10573:14)
      at printSourceFileOrBundle (../../node_modules/typescript/lib/typescript.js:78709:16)
      at emitDeclarationFileOrBundle (../../node_modules/typescript/lib/typescript.js:78671:17)
      at emitSourceFileOrBundle (../../node_modules/typescript/lib/typescript.js:78589:13)
      at forEachEmittedFile (../../node_modules/typescript/lib/typescript.js:78497:30)
      at Object.emitFiles (../../node_modules/typescript/lib/typescript.js:78578:9)
      at emitWorker (../../node_modules/typescript/lib/typescript.js:83228:33)

Test Suites: 1 failed, 1 total

The latter coming from here: https://github.com/Microsoft/TypeScript/blob/master/src/services/transpile.ts#L79

Minimal repo :

https://github.com/emirotin/learn-a

Most helpful comment

hi, we haven't looked into supporting TypeScript 3.x yet. We will take into account of this.

All 11 comments

The first bug is a problem with ts-node which has been fixed here (awaiting release):
https://github.com/TypeStrong/ts-node/pull/657

The second bug is one that I am currently also experiencing and have been unable to solve.

hi, we haven't looked into supporting TypeScript 3.x yet. We will take into account of this.

Yup, turning off "composite": true in tsconfig.json solved this issue (we're still just experimenting with the composite project feature anyway).

I am receiving the same error (b). Hope to see support for this soon! Using TS3's new Project References feature along with Lerna in a monorepo.

@emirotin I am having issues cloning your minimal repo. At the step yarn build (after prepare):

❯ yarn build
yarn run v1.9.4
warning package.json: No license field
$ tsc -b packages
error TS6059: File '/Users/huafu/tools/tests/ts-jest/learn-a/packages/pkg2/test/testing.test.ts' is not under 'rootDir' '/Users/huafu/tools/tests/ts-jest/learn-a/packages/pkg2/src'. 'rootDir' is expected to contain all source files.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'll try to change the exclude section... but why do we need to build to run tests?

It's just part of my original setup in the real project. Also it ensures TS config is fine.

@emirotin if you feel like it, you can test our latest beta with your full project. See #697 ;-)

Hi @huafu, I just gave it a try in my project and it seems to work fine 👍

thanks, one thing to start with is remove most ts-jest specific config fom jest.config.js and replace it with the preset. Example:

https://github.com/huafu/bs-logger/commit/4b480a0957e9221fa778bc4646c4cbb1a903ff78#diff-2d0cd5d10b9604941c38c6aac608178a

Would it be possible to add *.integ.ts to the preset?

@hassankhan it's not one used by jest for JS files, ie not a standard one, so I don't think it's a good idea to add it to the preset. But it's a preset, and you can also grain extend it. Please for further question(s) related to beta or suggestions, use the new slack channel.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GeeWee picture GeeWee  ·  4Comments

artola picture artola  ·  3Comments

Slessi picture Slessi  ·  3Comments

jbreckmckye picture jbreckmckye  ·  3Comments

AlexGellert picture AlexGellert  ·  4Comments