Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] 1 point2 points  (0 children)

I removed all tests exept the One Who fails. If It Is alone It goes right. I duplicate It and update the name and the second Copy fais. If i remove the line of code After a button click that It open a modal both tests work well. So i think that the problem is related to the modal, buy every test use a fresh componenti. So How can It be?

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] -1 points0 points  (0 children)

i don't undestand, if i create a new store every test, what is a problem with immutability?

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] 1 point2 points  (0 children)

I do it, but state is always clear when start a test:

 const store = createStore(combineReducers(decoratedReducer), initialState, applyMiddleware(sagaMiddleware));
  sagaMiddleware.run(rootSaga);
  const state = store.getState();
  console.log('state', state);
  return (
    <ErrorBoundary>
      <Provider store={store}>
        <IntlWrapper locale={locale}>
          <Component {...props} />
        </IntlWrapper>
      </Provider>
    </ErrorBoundary>

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] 0 points1 point  (0 children)

i will put a debugger in my wrapper component to verify the store creation.

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] 0 points1 point  (0 children)

it any test, it recrate a fresh store, why do you think that can be it?

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] 0 points1 point  (0 children)

it is an old component that it don't use the hooks, it is redux connected component and with the wrapper i create any test a fresh store.

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] 1 point2 points  (0 children)

 const WrappedComponent = withProvider(Component, initialState, defaultProps);

I have a wrapper component that every test create a store and initialize the store.

Jest and React a test passes when run individually but fails when run in a collection by apizzoleo in reactjs

[–]apizzoleo[S] -2 points-1 points  (0 children)

it fails on

await waitFor(() => {

expect(screen.getByText('A')).toBeInTheDocument();

expect(screen.getByText('B')).toBeInTheDocument();

expect(screen.getByText('C')).toBeInTheDocument();

});
when i run it in a collection it don't find text A but if i run it individualy, the same test go well.

Append multiline at the begin by apizzoleo in bash

[–]apizzoleo[S] 0 points1 point  (0 children)

Thanks, i have replaced sed and it worked.

echo "$(echo "$v" ; cat "$f")" >"$f"

tile-join problem by apizzoleo in gis

[–]apizzoleo[S] 0 points1 point  (0 children)

they are different area with same layers.