Why was context removed in a point release? #2468

Closed
randycoulman opened this Issue Dec 29, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@randycoulman

Do you want to request a feature or report a bug?

Question/Feature

What is the current behavior?

I have a test suite that was working fine with Jest 18.0. When I upgraded to Jest 18.1, many of my tests started failing with the message, "ReferenceError: context is not defined".

It appears that context was removed as a synonym of describe in #2384, but no reasoning was given there, other than that it was "unused".

It seems like such a breaking change should not have been introduced in a point release.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?

My understanding was that context was provided as an alias for describe to make it easier to port tests from other frameworks to Jest. Certainly, this is the case for us, as we've been migrating several projects from Mocha to Jest recently.

In many situations, I find context to communicate my intentions better than describe, so I really like having the alias.

I would like to see the context alias restored and documented as part of Jest's API. To me, it is similar to having it and test as aliases of each other.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Jest 18.1.0
Yarn 0.18.1
Node 6.9.2
OS/X 10.11.6

@cpojer

This comment has been minimized.

Show comment
Hide comment
@cpojer

cpojer Dec 30, 2016

Contributor

Context was controversial when it was added in #1632. We are currently rewriting the documentation of Jest and were analyzing the globals we add and realized context was almost entirely unused so we decided to remove this alias again. If you'd like to bring it back, you can do global.context = describe in a setupTestFrameworkScriptFile setting.

As to why this happened in a minor, here is what happened:

  • We made a ton of changes on master.
  • Right before Christmas, node 7.3 came out which has some buggy behavior which broke a ton of timer and console related things in Jest.
  • I was happily on a vacation and noticed that everything now sucks for our users so I decided to spend some time fixing it.
  • I tagged 18.1 because I didn't think the current amount of changes warranted a major release.
  • I did not tag 18.0.1 from an 18.x branch because this project doesn't have the resources to support branches like that. If you'd like to help out with release management on Jest, please let me know – I'd love to have your support!
Contributor

cpojer commented Dec 30, 2016

Context was controversial when it was added in #1632. We are currently rewriting the documentation of Jest and were analyzing the globals we add and realized context was almost entirely unused so we decided to remove this alias again. If you'd like to bring it back, you can do global.context = describe in a setupTestFrameworkScriptFile setting.

As to why this happened in a minor, here is what happened:

  • We made a ton of changes on master.
  • Right before Christmas, node 7.3 came out which has some buggy behavior which broke a ton of timer and console related things in Jest.
  • I was happily on a vacation and noticed that everything now sucks for our users so I decided to spend some time fixing it.
  • I tagged 18.1 because I didn't think the current amount of changes warranted a major release.
  • I did not tag 18.0.1 from an 18.x branch because this project doesn't have the resources to support branches like that. If you'd like to help out with release management on Jest, please let me know – I'd love to have your support!

@cpojer cpojer closed this Dec 30, 2016

@randycoulman

This comment has been minimized.

Show comment
Hide comment
@randycoulman

randycoulman Dec 30, 2016

@cpojer Thanks for the response. First, let me apologize for the tone of my original issue. I didn't spend enough time on it, and it came across sounding much harsher than I intended. I'm also sorry that you had to give up some vacation time to deal with an issue caused by someone else's change. I really appreciate the work you all have done on this project. It's because of that work that I'm even looking at Jest as an option.

I had thought about the global.context = describe solution, but I've already run across two tools this week that don't support context: globals and eslint-plugin-jest. That's why I was hoping for context to become a documented feature.

That said, I understand your reasoning for dropping it, though I disagree. And I understand the unfortunate circumstances that resulted in that happening on a point release. I'm not a big fan of multiple release tracks, so I wouldn't suggest you make your process more complicated than it is.

Again, thanks everyone for your work on the project!

@cpojer Thanks for the response. First, let me apologize for the tone of my original issue. I didn't spend enough time on it, and it came across sounding much harsher than I intended. I'm also sorry that you had to give up some vacation time to deal with an issue caused by someone else's change. I really appreciate the work you all have done on this project. It's because of that work that I'm even looking at Jest as an option.

I had thought about the global.context = describe solution, but I've already run across two tools this week that don't support context: globals and eslint-plugin-jest. That's why I was hoping for context to become a documented feature.

That said, I understand your reasoning for dropping it, though I disagree. And I understand the unfortunate circumstances that resulted in that happening on a point release. I'm not a big fan of multiple release tracks, so I wouldn't suggest you make your process more complicated than it is.

Again, thanks everyone for your work on the project!

@cpojer

This comment has been minimized.

Show comment
Hide comment
@cpojer

cpojer Dec 30, 2016

Contributor

Thanks for your response. ❤️

Contributor

cpojer commented Dec 30, 2016

Thanks for your response. ❤️

@raulmt raulmt referenced this issue in jest-community/eslint-plugin-jest Feb 16, 2018

Open

Are you open to support `context` as `describe` alias? #83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment