title: How to test a redux toolkit slice using createAsyncThunk with Jest?
body: <p>I'm trying to test the following slice (simplified version without right typing):</p>
  <pre><code>interface MyState {
    data: any[];
  }
  
  const initialState: MyState = {
    data: [],
  };
  
  export const postData = createAsyncThunk(
    'data/postData',
    async (
      param: {
        data: any[];
      },
      { rejectWithValue },
    ) =&gt; {
      try {
        const myService: MyService = new MyService();
        return await myService.postData(param.data);
      } catch (error) {
        console.error(error.message);
        return rejectWithValue(error.message);
      }
    },
  );
  
  const combineExtraReducers = (
    builder: ActionReducerMapBuilder&lt;MyState&gt;,
  ) =&gt; {
    builder.addCase(getData.fulfilled, (state, { payload }) =&gt; {
      state.data = payload;
    });
  };
  
  export const dataSlice = createSlice({
    name: 'data',
    initialState: initialState,
    reducers: {},
    extraReducers: (builder) =&gt; {
      combineExtraReducers(builder);
    },
  });
  </code></pre>
  <p>How can I write a simple test for this slice? I'm fine without createAsyncThunk, but I can't manage to write a test with the thunk.</p>
  <p>The approach from the official <a href="https://redux.js.org/usage/writing-tests" rel="nofollow noreferrer">redux toolkit documentation</a> does not work either. I get an error message regarding timeout.</p>
  <p>We're using <a href="https://www.npmjs.com/package/axios" rel="nofollow noreferrer">axios</a> as HTTP client.</p>