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

import jest functions instead of having globals #5192

Closed
apflieger opened this issue Dec 28, 2017 · 8 comments · Fixed by #9801
Closed

import jest functions instead of having globals #5192

apflieger opened this issue Dec 28, 2017 · 8 comments · Fixed by #9801

Comments

@apflieger
Copy link

Feature request or documentation missing?
I'd like to do

import {test, expect} from 'jest'

The current behaviour with globals works but it's just not convenient because IDEs don't recognize the functions.

Here are some stackoverflow related to this:
https://stackoverflow.com/questions/41324636/how-to-import-jest/43964557#43964557
https://stackoverflow.com/questions/41143700/how-to-import-describe-expect-and-it-into-a-typescript-tests-for-ide-to-n

@mrmckeb
Copy link

mrmckeb commented Dec 29, 2017

@apflieger, I find that VSCode works fine if you install the Jest typings.

@apflieger
Copy link
Author

I couldn't find a way to make it work in IntelliJ

@SimenB
Copy link
Member

SimenB commented Dec 29, 2017

Duplicate of #4473

@SimenB SimenB marked this as a duplicate of #4473 Dec 29, 2017
@SimenB SimenB closed this as completed Dec 29, 2017
@SimenB
Copy link
Member

SimenB commented Dec 29, 2017

IDE compatibility is pretty good if you use typings from either flow or typescript

@cyrilchapon
Copy link

It's also not convenient because it breaks standardjs.
Of course, we can

  • Add global ignore of jest it and other functions in standard config
  • just go for import { it } from global

But I like to think that, if a linter complies, it's because it's a bad practise. And indeed everything in global is a bad practise, at the root of some evils.

Mocha supports it. Any plan to add it ?

@SimenB
Copy link
Member

SimenB commented Nov 9, 2018

We have some vague plans to support it, but nothing concrete at this point. It is a feature we want, though 🙂

@SimenB
Copy link
Member

SimenB commented Apr 12, 2020

This will be available in the next version of Jest via #9801.

@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.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants