Multiple Typescript typing files both export 'expect' to global

Viewed 889

We have an Angular project in VS Code that has both cypress and jest installed for tests. The typings for both these packages declare the expect:

jest index.d.ts:

declare const expect: jest.Expect;

cypress index.d.ts:

// Cypress adds chai expect and assert to global
declare var expect: Chai.ExpectStatic

cypress and jest work, the problem is code intellisense seems to randomly fail to resolve the expect method in jest tests. I've tried to move the expect into a namespace but then I get this error: A 'declare' modifier cannot be used in an already ambient context. Renaming one of the declarations would work to make it appears ok in intellisense but would fail when running the tests.

How can I get it so VS code intellisense recognizes the correct expect based on if it's a cypress test or jest?

0 Answers
Related