Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest.Global incorrectly extends interface 'NodeJS.Global'? #8926

Closed
bartekleon opened this issue Sep 7, 2019 · 13 comments
Closed

jest.Global incorrectly extends interface 'NodeJS.Global'? #8926

bartekleon opened this issue Sep 7, 2019 · 13 comments

Comments

@bartekleon
Copy link

bartekleon commented Sep 7, 2019

Hello dear Jest fellows,
i've been doing some maintenance stuff in stryker-mutator and came into this error:

packages/jest-runner/node_modules/@jest/types/build/Global.d.ts:54:18 - error TS2430: Interface 'import("/home/travis/build/stryker-mutator/stryker/packages/jest-runner/node_modules/@jest/types/build/Global").Global' incorrectly extends interface 'NodeJS.Global'.
  Types of property 'describe' are incompatible.
    Type 'Describe' is not assignable to type 'SuiteFunction'.
      Types of property 'only' are incompatible.
        Type 'DescribeBase' is not assignable to type 'ExclusiveSuiteFunction'.
          Type 'void' is not assignable to type 'Suite'.
54 export interface Global extends NodeJS.Global {

We don't get any other error related to that so I am not sure why is it occurring (all i have done is to change dependencies from jest: ^24.9.0 to ~24.9)

Do you have any idea why it happened?

link to a PR: stryker-mutator/stryker-js#1706
link to a one of travis jobs: https://travis-ci.org/stryker-mutator/stryker/jobs/582083380

@thymikee
Copy link
Collaborator

thymikee commented Sep 8, 2019

@jeysal would you mind taking a look?

@SimenB
Copy link
Member

SimenB commented Sep 8, 2019

We don't get that error when building (using the latest TS 3.6), but maybe it's an issue with older versions of TS?

all i have done is to change dependencies from jest: ^24.9.0 to ~24.9

24.9.0 is the latest 24 release, so just changing that part wouldn't make a difference. Something else changed. I'd take a look at any lockfiles you might have.

@jeysal
Copy link
Contributor

jeysal commented Sep 9, 2019

Looks like a conflict with another framework defining the describe global

@bartekleon
Copy link
Author

Probably it is conflicting with mocha since i have seen some errors like 'it' has already been declared

@aqumus
Copy link

aqumus commented Oct 31, 2019

@kmdrGroch U happen to find any resolution, as even in one of my project, getting same error

@bartekleon
Copy link
Author

I think it was related that both jest and mocha (and more test runners/frameworks) were installed in the same project. I guess there was some problems with namespaces and so typescript assumed that these functions were defined in several places. So I can say it is solved.

@bartekleon
Copy link
Author

@aqumus try npm prune or remove / reinstall test frameworks / runners if you have more than 1

@drudv
Copy link

drudv commented Nov 22, 2019

I had a similar issue because there was another node_modules folder on top of my project's folder. The errors disappeared, when I removed those node_modules.

@bartekleon
Copy link
Author

I think it can be closed with these solutions :)

@codeviking
Copy link

We ran into this recently. Ultimately it was because:

Our solution was to replace expect with chai, as it doesn't depend upon @jest. We could've also likely replaced mocha with jest, but that felt like a larger effort.

@SimenB
Copy link
Member

SimenB commented Feb 4, 2020

This was fixed in Jest@25 (and expect@25) btw - it should play nice with mocha's global definitions. #9415

@codeviking
Copy link

@SimenB Great! I confirmed that expect@25 resolved the issue.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants