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

Feature requests for jest-circus #4371

Closed
ide opened this issue Aug 26, 2017 · 7 comments
Closed

Feature requests for jest-circus #4371

ide opened this issue Aug 26, 2017 · 7 comments
Labels

Comments

@ide
Copy link
Contributor

ide commented Aug 26, 2017

I'm looking into running Jest in RN and with the beta version of jest-circus. I had a couple of questions and feature requests for jest-circus I was hoping to share as the team works on it.

Starting with some questions: what is the vision for jest-circus? Conceptually, what is the interface that jest-circus provides? Is jest-circus intended to inject describe/beforeEach/afterEach/it/etc... into the global environment and then run the tests immediately?

I also have a couple of feature requests after looking though and using some of the jest-circus modules:

  • I like the way the state is separated from actually running the tests in the implementation. This way I can load all the tests and display them in a UI without running them. Could this separation be preserved as part of the jest-circus API?
  • I would like an API for more control over jest-circus's state. For example, say I load many test modules (each with their own describe calls). I would like to access jest-circus's state (either via the event handlers or with getState), display all the tests to the user, and then let the user choose which tests to run -> I want to take part of jest-circus's state and pass it to run() instead of run() using jest-circus's shared state. Perhaps jest-circus should be less stateful and more functional? (from the caller's perspective: add event listener -> call describe() -> event listener gets state -> pass state into run() -> get results)
  • Could there be a way to specify the global object that jest-circus uses for defining global.it, global.beforeEach, etc? The reason is that I'd like to run the tests in the same JS context as the test-runner (similar to Jest's in-band mode) and don't want to modify the actual global object. So if I could pass an object into jest-circus to use as the global object, that'd be helpful.

@aaronabramov cpojer tells me you would be a good person to ask about all this

BTW running jest-circus on the device (instead of driving the tests from Node) is pretty sweet. We can now access Views and other native APIs from within tests, really nice when the unit under test includes device state :D

@suchipi
Copy link
Contributor

suchipi commented Aug 27, 2017

@cpojer @aaronabramov As part of the second bullet, we could pull the module-level state in jest-circus/src/state.js into an object. So instead of the module exporting addEventHandler, dispatch, getState, and setState, it could export eg makeCircusState which returns an object with all those functions on it.

@aaronabramov
Copy link
Contributor

oh.. i posted the my reply yesterday, but it seems like there was a network error and it eventually didn't get posted :(

@ide i think all three features are possible to have with jest-circus.
Initially i wanted to make it as modular and functional as possible. The hardest challenge is going to be dealing with globals. I wanted to do pretty much the same thing as @suchipi said. i wrote a small summary here #3786 (comment)

@ide
Copy link
Contributor Author

ide commented Aug 29, 2017

@aaronabramov oh man, that sucks when your post gets lost like that, sorry :(

@suchipi's suggestion would work for me, right now I'm mutating the global Jest state. It'd also be nice (when the time comes) to know what parts of the state are considered the public API (ex: which events are public, which state fields are public) and what parts are implementation details that are more likely to change.

@rickhanlonii
Copy link
Member

Bumping this based on the new circus work we're doing

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 26, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@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 Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants