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.

Test improvements

See original GitHub issue

Working on #403 exposed a couple of potential improvements for the tests. I’m creating this issue to align which ones should actually be done, and how the changes should be grouped into PRs.

  • Reduce the usage of any in test files (#417)

    • Came up here
    • Would mean to add quite some type definitions to test files. Too much boilerplate? But types are nice, so I’m in favour of doing it.
  • Remove unnecessary mocks of console.error (#420)

    • Came up here
    • I guess the mocks are in for cases like this one. Still can be removed where not used.
  • Rename persistSync.test.tsx to .ts as it doesn’t contain any JSX.

  • Rename persist.test.tsx to persistAsync.test.tsx to be consistent. (#416)

  • Wrap tests in persist.test.tsx into a describe() block to be consistent with [persistSync.test.tsx] (#416)(https://github.com/pmndrs/zustand/blob/master/tests/persistSync.test.tsx)

    • or should this be done with all test files?
  • persist.test.tsx: Make sure that onRehydrateStorage was not called with an error (#423)

    • I noticed that the tests will not fail on errors occurring during state initialisation as the error is only passed to onRehydrateStorage. Therefore each test needs to verify that onRehydrateStorage was called with undefined.
    • I already added this check to persistSync.test.tsx (see example)
  • persist tests: Use jest.fn() to mock onRehydrateStorage instead of hand-crafting a spy (#423)

    • See here as example
    • No big deal, but my guess is that it would simplify the code, and make it more fail-safe
  • Add this test to the persist.test.tsx as well. (#430)

  • Add some structure to basic.test.tsx (#424)

    • Right now it’s 800 lines of it() calls 😅
    • One way to add a bit of structure would be to have each subscribe and type-related tests be grouped under a separate describe() call within the same file.
    • … or break up the file? Would need feedback on that one.
  • perstist*.test.tsx: Expand it(‘can persist state’) by verifying that the persisted state is actually written to the storage (#431)

    • One of the more important scenarios, right?
  • split tests for subscribe() into multiple it() blocks (#427)

  • replace callbacks with spies for subscribe() tests (#429)

  • persistAsync.test.tsx: Move component Counter to top of file

    • Tried it, doesn’t seem to be worth it. Will skip.
  • Address inconsistency of arguments for onRehydrateStorage between sync and async (#437)

  • Follow up on #431 (#436)

    • Implement also for async version.
  • Add tests for outer onRehydrateStorage callback`

    • At the moment the tests only test the function returned by onRehydrateStorage which is called after rehydration, not the one that’s called before rehydration.

I guess that all of those deserve separate PRs. So I’d just need to know which ones you want to be done, then I’d get going.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
barbogastcommented, Jul 30, 2021

Oh, right, the ticket is still open.

It can be closed as far as I’m concerned. One item is still open, but I’m doubtful that it’s important enough and worth the effort.

Closing…

2reactions
dai-shicommented, Jun 14, 2021

I’m fine. Having new ideas after some work is not surprising. Thanks for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Ideas for Continuous Improvement in Software Testing
6 Key Tips for Continuous Improvement in Software Testing · 1.Devising A Plan And Defining Strategy · 2.Scenario Analysis · 3.Test Data Identification...
Read more >
Test Process Improvement (TPI) using PDCA Model - Guru99
The first activity of a test improvement process is identifying the problems that occurred in the current project. The problems in this project ......
Read more >
11 Ways to Improve Software Testing through Planning, Work ...
Learn the ways to improve software testing and quality assurance ... test cases is an integral part of software testing improvements.
Read more >
Test Improvement Process - Better QA
Jlust as organizations use testing to improve software, process improvement techniques can be selected and used to improve the process of developing ...
Read more >
Software Testing Process Improvements for Test / QA Managers
Improvements to processes are essential for both software development and testing processes. If the organization learns from its own mistakes, processes used to ......
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