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

Question: Configuring jsdom for Jest #2484

Closed
jambonrose opened this issue Dec 31, 2016 · 4 comments
Closed

Question: Configuring jsdom for Jest #2484

jambonrose opened this issue Dec 31, 2016 · 4 comments

Comments

@jambonrose
Copy link

I tried Jest in January of 2016, and have just picked it up for a new React+Redux project (following the strong recommendation in create-react-app). The developer experience is radically different. Congrats on really amazing progress. 👏

I have a question with regards to interacting with jsdom. I'm currently trying to test a React component. The goal is to pass a mocked function and verify that the function is called when an img is loaded. Unfortunately, jsdom does not call onLoad by default. As shown in the jsdom docs and confirmed by @Sebmaster in #1017 I need to change the default value of FetchExternalResources in the jsdom configuration.

I'm trying to avoid re-creating a separate jsdom environment, and would like to access/modify/configure the jsdom environment used by Jest. Is there a way to do this? I suspect this may be related to #2460.

Thanks!

@thymikee
Copy link
Collaborator

thymikee commented Jan 3, 2017

Currently there's no way to do it. #2460 is related, but there's no guaranty it will be implemented. Although we could add a "jsdomConfig": {} option in configuration, which would allow to do just that. Feel welcome to send a PR on this if you like :).

Related files I can think of:

Closing for now.

@thymikee thymikee closed this as completed Jan 3, 2017
@cpojer
Copy link
Member

cpojer commented Jan 4, 2017

I think it makes more sense to expose global.jsdom = jsdom or something like it. Also, require('jsdom') may just work, no? I'd prefer not to add a config option like this, I think adding testURL was a bad design decision on my part early on.

@allenwq
Copy link

allenwq commented Mar 2, 2017

I'd think global.jsdom = jsdom is a good idea, otherwise it's too inflexible.

anyway we can access jasmine in the global scope already.

@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

4 participants