Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

typescript+jest incompatibilities #11

Closed
ianwremmel opened this issue May 7, 2018 · 2 comments
Closed

typescript+jest incompatibilities #11

ianwremmel opened this issue May 7, 2018 · 2 comments

Comments

@ianwremmel
Copy link

There seem to be a few issues with using fancy-test in a typescript project that doesn't use mocha/chai:

node_modules/fancy-test/lib/chai.d.ts(1,23): error TS2688: Cannot find type definition file for 'chai'.
node_modules/fancy-test/lib/chai.d.ts(2,30): error TS2503: Cannot find namespace 'Chai'.
node_modules/fancy-test/lib/types.d.ts(1,23): error TS2688: Cannot find type definition file for 'mocha'.
node_modules/fancy-test/lib/types.d.ts(2,24): error TS2307: Cannot find module 'mocha'.

I was able to fix that chai issue with

npm install @types/chai

I think that could work for mocha as well if one is not using a different test framework that declares the same function names. For example, if I run the following

npm install @types/mocha @types/chai

I end up with

node_modules/@types/jest/index.d.ts(20,13): error TS2300: Duplicate identifier 'beforeEach'.
node_modules/@types/jest/index.d.ts(22,13): error TS2300: Duplicate identifier 'afterEach'.
node_modules/@types/jest/index.d.ts(23,13): error TS2451: Cannot redeclare block-scoped variable 'describe'.
node_modules/@types/jest/index.d.ts(25,13): error TS2451: Cannot redeclare block-scoped variable 'xdescribe'.
node_modules/@types/jest/index.d.ts(26,13): error TS2451: Cannot redeclare block-scoped variable 'it'.
node_modules/@types/jest/index.d.ts(28,13): error TS2451: Cannot redeclare block-scoped variable 'xit'.
node_modules/@types/jest/index.d.ts(29,13): error TS2451: Cannot redeclare block-scoped variable 'test'.
node_modules/@types/mocha/index.d.ts(41,15): error TS2451: Cannot redeclare block-scoped variable 'describe'.
node_modules/@types/mocha/index.d.ts(42,15): error TS2451: Cannot redeclare block-scoped variable 'xdescribe'.
node_modules/@types/mocha/index.d.ts(47,15): error TS2451: Cannot redeclare block-scoped variable 'it'.
node_modules/@types/mocha/index.d.ts(48,15): error TS2451: Cannot redeclare block-scoped variable 'xit'.
node_modules/@types/mocha/index.d.ts(50,15): error TS2451: Cannot redeclare block-scoped variable 'test'.
node_modules/@types/mocha/index.d.ts(66,18): error TS2300: Duplicate identifier 'beforeEach'.
node_modules/@types/mocha/index.d.ts(67,18): error TS2300: Duplicate identifier 'beforeEach'.
node_modules/@types/mocha/index.d.ts(68,18): error TS2300: Duplicate identifier 'afterEach'.
node_modules/@types/mocha/index.d.ts(69,18): error TS2300: Duplicate identifier 'afterEach'.

I was only able to solve the mocha problem by excluding test files from tsc.

@jdx
Copy link
Collaborator

jdx commented May 7, 2018

I can probably get rid of the mocha types actually, let me see

@jdx jdx closed this as completed in d011192 May 7, 2018
@ianwremmel
Copy link
Author

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants