Comments (7)
@fatso83 I'll try to clarify:
On timeout
property that waitForServerToFulfillRequests
uses.
My original goal was to have a way to stop the setInterval
checks.
The scenario in my mind was: the tests have failed (eg. 2000 ms passed) and I still do the checks, I want to stop. Testing frameworks allow tests to run even if one failed so I don't want to leave this check in the background.
I could stop the setInterval checks inside waitForServerToFulfillRequests
by using a checkCount
equal to autoRespondAfter
* this.responses.length
+ 1.
If you refer to my pointing out you need to return a value, it had nothing to do with testing and everything to do with the fact that your example wasn't runnable, as the .then() would result in a NullPointer exception.
I updated the example:
function reloadApp() {
$.ajax({url: "first/url"}).then(() => {
$.ajax({url: "second/url"}).then((htmlFragment) => updateDOM(htmlFragment));
return "<markup />";
}).then((htmlFragment) => updateDOM(htmlFragment));
}
updateDOM
- this can do simple stuff like .appendChild
or create/update custom web components.
PS: you can run the POC here https://github.com/serbanghita/karma-mocha-chai-sinon
from nise.
This is like lolex
's runAllTimers
. Seems like a nice addition?
P.S. For reloadApp().then((r1) ...
to work your reloadApp
function needs to return something.
from nise.
@fatso83 thanks for pointing that out. I can make a PR, i'm trying to understand how to test this in isolation and in the cotext of Sinon afterwards. I want the timeout
property to be dictated from the frameworks timeout settings.
On reloadApp
, I didn't care about testing the return value of that, the use case is more about "waiting for all the XHRs to finish"
from nise.
There's too many unclear things you refer to for me to understand what you talk about.
I want the timeout property to be dictated from the frameworks timeout settings.
Which timeout
property are you talking about?
The autoRespondAfter
timeout? Or the timeout
parameter in your example function waitForServerToFulfillRequests
?
Which framework are you talking about?
The testing framework? If so, please don't. We don't want test details to be connected with details of Mocha/Ava/... or something else. I don't see any mention of a timeout above. Also, I don't think Mocha exposes hooks to read it, only set it using this.timeout(millis)
On reloadApp, I didn't care about testing the return value of that
What is "that" referring to? If you refer to my pointing out you need to return a value, it had nothing to do with testing and everything to do with the fact that your example wasn't runnable, as the .then()
would result in a NullPointer exception.
from nise.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from nise.
This has a PR that's waiting review.
from nise.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from nise.
Related Issues (20)
- FakeXHR and Event Targets HOT 8
- Rollup throws warnings about `nise` complaining the usage of `eval` HOT 5
- TypeError: GlobalTextEncoder is not a constructor HOT 4
- [HELP] can't respond to xhr: INVALID_STATE_ERR - 4 HOT 6
- Expose a way of choosing an alternate target HOT 1
- "Defaked" fake XHR does not propagate properties to actual XHR after triggering `open` HOT 2
- Timeout isn't working as expected HOT 10
- URLs with port fail to match & respond on fake-server
- URLs with specified ports override/match responses of different ports
- `readystatechange` event should not be triggered after `loadend` HOT 2
- text-encoding dependency is not available anymore HOT 1
- Experiment: Create `.d.ts` files from JSDOc HOT 3
- Error when setting unsafe headers HOT 3
- [Docs] Should docs be updated or removed? HOT 2
- Is there a way to catch non-mocked responses? HOT 3
- `TypeError: performance.mark is not a function` on node@16 HOT 2
- responseType=document only supports XML not HTML HOT 2
- Module entry point "nise.js" is wonky HOT 5
- Error: Cannot find module 'text-encoding' HOT 1
- readystatechange OPENED event triggered on send() HOT 9
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 nise.