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

new jest globals #1632

Merged
merged 1 commit into from
Sep 7, 2016
Merged

new jest globals #1632

merged 1 commit into from
Sep 7, 2016

Conversation

aaronabramov
Copy link
Contributor

added some globals that i always wanted.

xtest
test.only
test.skip

context
xcontext
context.only
context.skip

describe.only
describe.skip

we also need to add them to all the lint rules

@cpojer
Copy link
Member

cpojer commented Sep 7, 2016

that is a ton of new globals.

@aaronabramov
Copy link
Contributor Author

worth it!

still, i think the ideal solution would be to enable

{
  globals: false
}

in the config and then

import {it, describe} from 'jest';

@cpojer
Copy link
Member

cpojer commented Sep 7, 2016

but we can't actually shadow jest with our own module because how are you gonna require jest in a jest test then?

@aaronabramov
Copy link
Contributor Author

https://github.com/facebook/jest/blob/master/packages/jest/src/jest.js

i think we can actually export it here instead of proxying jest-cli and leave cli to jest-cli :)

do we have anything that uses require('jest') programmatically?

@cpojer
Copy link
Member

cpojer commented Sep 7, 2016

I mean, we can probably survive.

tbh I kind of want to keep the globals. I'm not happy with the one-line boilerplate in every test…

@codecov-io
Copy link

codecov-io commented Sep 7, 2016

Current coverage is 89.93% (diff: 100%)

Merging #1632 into master will not change coverage

@@             master      #1632   diff @@
==========================================
  Files            31         31          
  Lines          1143       1143          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           1028       1028          
  Misses          115        115          
  Partials          0          0          

Powered by Codecov. Last update 96844eb...551ac8e

@kentcdodds
Copy link
Contributor

Reeeally hoping this'll land :)

@@ -0,0 +1,22 @@
exports[`test global jest variables 1`] = `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THIS IS SOOOOO COOOOL!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually an awesome use of snapshot testing!

@cpojer
Copy link
Member

cpojer commented Sep 7, 2016

I feel like context is a very common variable name as opposed to describe and it. I don't really think we should add it now.

@kentcdodds
Copy link
Contributor

Personally, I never use context, so I don't really care one way or the other, but I don't see why the existence of context on global would inhibit anyone who wanted to use a variable called context.

@aaronabramov
Copy link
Contributor Author

yeah. let's kill context. its semantics is hard to understand too

@fson
Copy link
Contributor

fson commented Sep 7, 2016

A pull request should probably be opened to add xtest in the Jest globals in https://github.com/sindresorhus/globals?

@cpojer
Copy link
Member

cpojer commented Sep 7, 2016

@DmitriiAbramov is way ahead of you: sindresorhus/globals#97

@ghost ghost added the CLA Signed ✔️ label Sep 7, 2016
@maximderbin
Copy link
Contributor

@DmitriiAbramov ruby will never go out from your blood hahah

@vjeux
Copy link
Contributor

vjeux commented Sep 12, 2016

@DmitriiAbramov are you going to add them to the documentation? Otherwise it's a pretty undiscoverable feature.

http://facebook.github.io/jest/docs/api.html#the-jest-global-environment

@aaronabramov
Copy link
Contributor Author

@vjeux yes! i'll submit a PR with the docs a bit later :)

@github-actions
Copy link

This pull request 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 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants