Any idea to test this generator function?
See original GitHub issueexport function * getData () {
let task
while (true) {
let { data } = yield take(types.GET_DATA)
task && task.isRunning() ? yield cancel(task) : null
task = yield fork(callApi, data)
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to test a generator function called using CO
How to test a generator function called using CO ; //My add function var ; fn = (a,b)= ; //My generator function var...
Read more >How do you test a function that returns a Generator? - Laracasts
Hi I have a simple service that will fetch a data api and then loop it with generator. and i dont have any...
Read more >Transparent unit tests using ES generators | by Matt Miller
Here's where we can see the real power of testing generator functions. Each time the function under test needs to request outside information,...
Read more >Generators - The Modern JavaScript Tutorial
To create a generator, we need a special syntax construct: function* , so-called “generator function”. It looks like this:.
Read more >Test Data Generator Functions - BlazeMeter Docs
The parameter values for Test Data Generator functions are ECMAScript 6 expressions. An expression can be numbers, text, functions, functions, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@n9ti v0.6.0 introduces
createMockTask
. see releases notes for usage exampleHey! I wonder how come setting
mockTask.setRunning(false)
in the test doesn’t effect the previous task? I mean, if it is set totrue
, then obviously a cancellation should be called. But if it’sfalse
, shouldn’t the generator just fork and skip the cancellation?