How to use Mocha and Jest with TypeScript without conflicts?

前端 未结 2 1083
挽巷
挽巷 2021-02-20 03:19

I\'m trying to install Mocha and Jest with types on one project. We use strict typecheck, so I get errors related to conflicting globals type.

I\'ve tried to create ambi

相关标签:
2条回答
  • 2021-02-20 04:01

    As of August 2019, this appears to have been fixed on master, but a new version has not been released yet.

    In the meantime, I was able to address these errors by adding the following to one of my definitions:

    declare module '@jest/types/build/Global' {
      interface DescribeBase extends mocha.SuiteFunction {}
      interface ItBase extends mocha.TestFunction {}
    }
    
    0 讨论(0)
  • 2021-02-20 04:03

    I searched through package lock file to see which dependencies use @types/jest and found out that in my case I still have ts-jest in my project which I removed and conflicts disappeared

    0 讨论(0)
提交回复
热议问题