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.

[Proposal] Use the testing framework assertion library for better integration

See original GitHub issue

The current behavior is unmet expectation is to throw an error with a formatted string of unmet expectations.

For small examples it is not an issue, however, when you have nested objects to assert (e.g. 2 level deep objects) or many effects to except the error message becomes very unreadable. It is hard to find what exactly didn’t match.

If we use the testing framework, for example jest, assertion library (expect) errors will be printed using the library’s reporter.

In my case, they will be formatted by WebStorm reporter which have a nice diff view which I missing when using redux-saga-test-plan.

What do you think about this proposal?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:16

github_iconTop GitHub Comments

5reactions
mike1808commented, May 8, 2019

@borrascador it’s the built-in expect in Jest. Try to use it in https://github.com/jfairbank/redux-saga-test-plan/blob/master/src/expectSaga/expectations.js file instead of throw

2reactions
mike1808commented, Aug 3, 2019

For those who are interested. Unfortunately, I didn’t have time to make the code more organized, however, Jest integration works perfectly. I tested my previous project which had a lot of saga tests using this library.

The code is available in my forked repo on this branch https://github.com/mike1808/redux-saga-test-plan/tree/beta-jest

You can try on your projects by installing jest-redux-saga-test-plan@4.0.0-beta.5

Few caveats:

  1. This branch is created from upgrade-to-babel7 as its new versions of babel was required to use the new Jest version.
  2. The compatibility for old Node.js might be broken because I upgraded Babel and removed some polyfills in the code (like Map), so my fork might not work on Node.js < 8
  3. The main code changes are in src/shared/serializeEffect.js file. There you can find that some effects like CANCELLED, FLUSH, CANCEL, JOIN are not implemented.
  4. The changes are only for expectSaga. I didn’t touch the unit testing API.

If you have any question about code, feel free to write here, or, if you want to continue my work, we can set up a zoom/skype call and I’ll share all context I have.

cc @dbartholomae @vov462 @Taguhi

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between a test runner, testing framwork ...
The assertion library is what actually runs the specs and determines whether any given condition is valid or not. Ultimately, every test is...
Read more >
Exploring the landscape of Go testing frameworks
The library gocheck offers similar functionality to Testify. It's a testing framework with support for rich assertions, the definition of test ...
Read more >
Golang Testing Frameworks for Every Type of Test - Speedscale
Testing frameworks offer a range of benefits. They include utilities like assertions and matchers that aren't present in the testing package.
Read more >
API Testing: Approaches, Tools, and Frameworks - AltexSoft
API testing kills bugs early in the development cycle. How to test APIs, which tool to use: Postman, Rest Assured, or jMeter, why...
Read more >
Comparing the best Node.js unit testing frameworks
It aims to run on any JavaScript-enabled platform and is highly flexible and compatible with a variety of other testing frameworks and libraries...
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