-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent race conditions when loading account #868
Conversation
MegaLinter status: ✅ SUCCESS
See errors details in artifact MegaLinter reports on CI Job page |
Codecov Report
@@ Coverage Diff @@
## master #868 +/- ##
==========================================
+ Coverage 88.29% 88.41% +0.12%
==========================================
Files 97 97
Lines 1606 1606
Branches 336 336
==========================================
+ Hits 1418 1420 +2
+ Misses 188 186 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
testSaga(accountSaga) | ||
.next() | ||
.fork(refreshAccountOnTransaction) | ||
.next() | ||
.takeLatest(accountActions.fetchAccount, loadAccount) | ||
.next() | ||
.isDone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a useful test.
I'd rather see approximately
expectSaga(stakingSaga)
.provide(getAccount, () => delay(10*Math.random()))
.put(fetchAccount('a'))
.put(fetchAccount('b'))
.hasFinalState({ address: 'b' })
.run()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this unit test if valid unless I am missing something, but I am following one of redux saga test plan pattern. I am adding a unit test not integration test. Unit test is testing a watcher saga only and it doesn't care about integration with other parts of code. The bug exists because of using a wrong effect creator. Unit test is validating if a correct effect creator is used so it covers current bug/potential regression bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unit test is essentially "did source code change" and it will break on many non-regressions.
expect(accountSaga.toString()).toBe(`
export function* accountSaga() {
yield* fork(refreshAccountOnTransaction)
yield* takeLatest(actions.fetchAccount, loadAccount)
}
`)
testSaga becomes interesting when unit testing with different inputs in .next(_)
, so it tests behavior, instead of implementation.
5f8aa57
to
3a6f264
Compare
3a6f264
to
0766178
Compare
Closes #861