Comments (9)
I had noticed a few of these issues when I made #6. I don't see what problems would be caused with global variables, at least so far. The only things that are global is React, window, and document. So I'm a little unsure about what you want cleaned up after a test runs.
As for the canUseDom, I found it's the only way when using jsdom inside of the library because for some reason imports aren't always loaded in order (or something else weird is happening). This library is meant to run inside of node v4+ not in the browser.
Hope that helped answer some things. Btw, thank you so much for wanting to use this library :) It makes testing so much faster for me, and I would gladly add anything to it that would help you too!
from tests.
Thanks for your quick reply!
You are right, the tests run in node 4.
However, I'm using axios to make http requests for example and I'd like to test requests made within my app in my test suite too.
So in the browser, axios is using XMLHttpRequest and in node, they use the http library.
If you look at their code, they test for presence of XMLHttpRequest, which jsdom puts in the global.
It's totally possible to work around this by unsetting specific globals for certain tests but it does not feel like the perfect solution intellectually.
from tests.
I you want to have a look at the project I'm working on:
- The offensive line I want to get rid of in a perfect world
- Using legit-tests for beautiful tests ❤️
from tests.
Thanks for the links to your tests I see what you mean. The only thing I'm confused on now is that in the test you're doing to make an http request you're not including legit tests but I'm guessing it was included in another test and the globals are still there? If so then I see the problem.
from tests.
Also, I think you'll like what I just added #9 :)
Edit: that changeValues function looks really nice, you should send a PR with it as bundled middleware!
from tests.
@geowarin can you specify what you need done? I'm going to close this in a few days if there's no reply
from tests.
Hi @zackify !
I have no perfect solution for the moment.
Not being tied to a testing framework means that you have no hook to do proper cleaning.
Maybe you could optionally let the user do the jsdom init?
#9 is fantastic!
I'll push the changeValues middleware as soon as you review #19 😄
from tests.
I've just seen #14. It seems that we are moving towards an optional jsdom init, then.
from tests.
I'm thinking even though it's as easy as not including the dom.js file, I
might make this a different file "legit-tests/nodom" or something?
On Wed, Sep 23, 2015 at 02:49 Geoffroy Warin [email protected]
wrote:
I've just seen #14 #14. It
seems that we are moving towards an optional jsdom init, then.—
Reply to this email directly or view it on GitHub
#11 (comment).
from tests.
Related Issues (20)
- include jsdom in the library itself
- add configuration options HOT 1
- Add renderComponentToString middleware HOT 1
- Issue with Webpack HOT 19
- Usage in browser? HOT 12
- Add .element for testing elements HOT 1
- Add wrapper for testing Alt stores
- Improve the API HOT 7
- jsdom and node 12 vs node 4 HOT 5
- README doesn't work as expected with the .test callback HOT 4
- expect JSX? HOT 1
- referencing snake-cased class name selectors from .simulate() HOT 6
- harmony-reflect should be in dependencies HOT 5
- React 0.14-compatible version HOT 1
- improved CSS selectors for the find middleware? HOT 3
- Release 0.6.3 is broken HOT 3
- Support for react 15 in 1.1.x (or when is 2.0 expected?) HOT 3
- React error when testing components that include refs HOT 6
- Cannot find module "react/lib/ReactTestUtils" - [email protected] HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tests.