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.

Comparison of the generated selection functions

See original GitHub issue

Hi, i’m having some problems with comparison of the select functions: This is begining of my saga:

    export function* mySaga() {
        const { data } = yield select(componentSelectors.getComponent(componentId))
        
        /** some logick */
    }

and a test for her:

    it('Testing mySaga', () => {
        const componentId = 1;
        testSaga(mySaga)
            .next()
            .select(componentSelectors.getComponent(componentId))

            /** test continuation */
    });

When I run the test, I get an error: “select effects do not match”

    Expected
    --------
    { selector: [Function: bound ], args: [] }

    Actual
    ------
    { selector: [Function: bound ], args: [] }

And so it happens to all tests, where i’m using generated selector getComponent and other like him:

    const getComponents = state => state["components"];
    const getComponent = id => state => {
        const { [id]: component } = getComponents(state);
        return component;
    };
    export const componentSelectors= {
        getComponents,
        getComponent
        }
    }

Can I somehow use your library to compare the generated functions?

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
arnaudambrocommented, May 14, 2019

@pavel-rakhmanov I encountered the same issue, this is how I solved it:

import componentSelectors from '../selectors'
jest('../selectors')

it('Testing mySaga', () => {
  beforeAll(() => {
    const noOp = () => {}
    componentSelectors.getComponent.mockImplementation(() => noOp)
  })
  const componentId = 1;
  testSaga(mySaga)
      .next()
      .select(componentSelectors.getComponent(componentId))
      .next(/* component */)
      .isDone()
});
1reaction
cdowcommented, May 23, 2019

Another option that doesn’t involve any mocking is you can wrap the creation of your generated function with a call. This results in the original function looking like this:

export function* mySaga() {
  const componentSelector = yield call(componentSelectors.getComponent, componentId);
  const { data } = yield select(componentSelector);
        
  /** some logic */
}

This can then be tested with:

it('Testing mySaga', () => {
  const componentId = 1;
  const componentSelector = () => {};
  
  testSaga(mySaga)
    .next()
    .call(componentSelectors.getComponent, componentId)
    .next(componentSelector)
    .select(componentSelector)

    /** test continuation */
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to compare the performance of feature selection methods?
Feature selection performance can be evaluated by the overall performance of learning task for example one can select features with different methods and ......
Read more >
How to Choose a Feature Selection Method For Machine ...
Wrapper feature selection methods create many models with different subsets of input features and select those features that result in the best ...
Read more >
On Comparison of Feature Selection Algorithms
Feature selection (FS) is extensively studied in machine learning. We often need to compare two FS algorithms. (A1,A2). Without knowing true relevant features, ......
Read more >
Comparison of five supervised feature selection algorithms ...
Here, we used five state-of-the-art feature selection algorithms, viz., mRMR, DFS, INMIFS, SVM-RFE-CBR and VWMRmR to select a small subset of ...
Read more >
Comparison of Methods for Feature Selection in Clustering of ...
(2017) compared feature selection algorithms based on execution time, number of selected features and classification accuracy in two ...
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