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.

Hi, I want to ask about handling select saga effect in tests.

My use case is: expectSaga(mySaga).withReducer(myReducer, initialReducerState)

In saga implementation I’m just calling const param = yield select((wholeState) => wholeState.moduleState.param)

So in result following code it is crushing because select effect is returning initialReducerState instead of wholeState.

Is it expected behaviour? Can it be handled without using fakes?

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
olga-gizacommented, Aug 3, 2018

Yeah, to have my case covered, I used following mock:


expectSaga(mySaga)
...
.provide([
	[matchers.select.selector(selector), mockSelectorOutput]
])
...

Still I think that it is not so great to mock also the selectors so it would be cool to have that woking in the future.

4reactions
v-gachkovskycommented, Jul 24, 2018

I have some trouble in unit test too. I have this test:

  testSaga(updateSetting, { payload: setting })
    .next()
    .call(putRequest, '/settings', setting)
    .next()
    .select(selectSettings())
    .next(settings)
    .put(updateSettingSuccess(settings));

And got an error on a string with ‘select’:

● updateSetting › encountered a declaration exception

    SagaTestError: 
    Assertion 3 failed: select effects do not match

    Expected
    --------
    { selector: 
       { [Function]
         resultFunc: [Function],
         recomputations: [Function],
         resetRecomputations: [Function] },
      args: [] }

    Actual
    ------
    { selector: 
       { [Function]
         resultFunc: [Function],
         recomputations: [Function],
         resetRecomputations: [Function] },
      args: [] }

My selector is:

import { createSelector } from 'reselect';
import { NAMESPACE } from './constants';
import { selectNamespace } from 'utils/reduxHelpers';

const selectSettings = () => createSelector(
  state => selectNamespace(state)(NAMESPACE),
  namespace => namespace.settings
);

How can I fix this issue?

“react”: “16.3.1”, “redux”: “3.6.0”, “redux-saga”: “0.15.3” “redux-saga-test-plan”: “^4.0.0-beta.1”,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selection Effect — What It Is and Why It's Important
Selection Effect is the bias introduced when a methodology, respondent sample or analysis is biased toward a specific subset of a target ...
Read more >
What Is Selection Effect, and How Can I Avoid It? | Built In
Selection effect is a type of bias introduced when a methodology, respondent sample or analysis is skewed toward a specific subset of a...
Read more >
Selection bias - Wikipedia
Selection bias is the bias introduced by the selection of individuals, groups, or data for analysis in such a way that proper randomization...
Read more >
Selection Effects - Eso.org
Selection Effects. Several effects may bias samples of blazars, causing them to miss objects which fall within their survey area and flux limits....
Read more >
What is a “Selection Effect” in online testing? And why does it ...
Selection Effects is one of the 4 primary threats to test validity and represents the effect on a test variable, such as conversion...
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