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

Update getting started guide to avoid linter errors #3762

Closed
dandv opened this issue Jun 8, 2017 · 4 comments
Closed

Update getting started guide to avoid linter errors #3762

dandv opened this issue Jun 8, 2017 · 4 comments

Comments

@dandv
Copy link
Contributor

dandv commented Jun 8, 2017

Following the getting started guide and using a linter (e.g. one built into an IDE like WebStorm) will highlight test, expect and toBe in the test file as not defined:

image

An import should be added for jest.

@thymikee
Copy link
Collaborator

thymikee commented Jun 8, 2017

If you use ESLint, here's the plugin for you: https://www.npmjs.com/package/eslint-plugin-jest.
It's not a bug in Jest for sure, it's your linter.

@thymikee thymikee closed this as completed Jun 8, 2017
@dandv
Copy link
Contributor Author

dandv commented Jun 10, 2017

Never said this was a bug in Jest, and it's not a linter problem either (I've added and configured eslint-plugin-jest but that didn't help). It's just that any sort of editor that tries to understand your JS code will flag undefined symbols.

In other words, what require statements are necessary so that the test files can be run by node?

$ node index.test.js
[...]
ReferenceError: test is not defined

@thymikee
Copy link
Collaborator

test, amongst couple of others, is a global variable injected by Jest. You need to run your tests through jest, not node.

@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 13, 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

No branches or pull requests

2 participants