Unit tests - constancy of flows and data

I ran into a little problem with unit testing and stream data stores.

Since data warehouses are singletones that receive only one instance (when a module is imported), any changes you make to your unit test are saved.

It can (and is) cause me all kinds of headaches.

The solution I am currently implementing is the reset method for each repository that I run in afterEach, but I was wondering / hoping there is an easier way around this?

+5
source share
1 answer

Require a dispatcher, store and receive a callback link all within beforeEach (). This removes old material and gives you fresh material for each test.

An example of this on the blog: http://facebook.imtqy.com/react/blog/2014/09/24/testing-flux-applications.html#putting-it-all-together

+4
source

Source: https://habr.com/ru/post/1205285/


All Articles