question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any idea to test this generator function?

See original GitHub issue
export 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:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yelouaficommented, Feb 2, 2016

@n9ti v0.6.0 introduces createMockTask. see releases notes for usage example

0reactions
ghostcommented, Sep 8, 2016

Hey! I wonder how come setting mockTask.setRunning(false) in the test doesn’t effect the previous task? I mean, if it is set to true, then obviously a cancellation should be called. But if it’s false, shouldn’t the generator just fork and skip the cancellation?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found