oclif / fancy-test

extends mocha with helpful, chainable extensions

Home Page:https://npmjs.com/package/fancy-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

typescript+jest incompatibilities

ianwremmel opened this issue · comments

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.

commented

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

Thanks!