### Basic Saga Test with redux-saga-tester Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md This JavaScript example demonstrates a basic test for a Redux saga. It initializes SagaTester, starts the saga, dispatches a starting action, waits for a success action, and asserts the final action. Dependencies: redux-saga-tester, chai Inputs: Actions (standard Redux action creators) Outputs: SUCCESS action object ```javascript import ourSaga from './saga'; describe('ourSaga test', () => { let sagaTester = null; beforeEach(() => { // Init code sagaTester = new SagaTester({ initialState }); sagaTester.start(ourSaga); }); it('should retrieve data from the server and send a SUCCESS action', async () => { // Our test (Actions is our standard redux action component). Start the saga with the START action sagaTester.dispatch(Actions.actions.start()); // Wait for the saga to finish (it emits the SUCCESS action when its done) const successAction = await sagaTester.waitFor(Actions.types.SUCCESS); // Check that the success action is what we expect it to be expect(successAction).to.deep.equal( Actions.actions.success({ data: expectedData }) ); }); }); ``` -------------------------------- ### Install redux-saga-tester using npm Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md This command installs the redux-saga-tester package as a development dependency in your project. ```bash npm install --save-dev redux-saga-tester ``` -------------------------------- ### Comprehensive Saga Test with redux-saga-tester Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md This advanced JavaScript example showcases the full capabilities of redux-saga-tester. It demonstrates initializing the tester with initial state, reducers, and middleware, starting a saga, dispatching actions, asserting state changes, checking action history, and resetting the tester. Dependencies: chai-as-promised, redux-saga/effects, redux-saga-tester Inputs: Actions, Redux state, Middleware Outputs: State changes, Action history ```javascript import chaiAsPromised from 'chai-as-promised'; import { call, take, put } from 'redux-saga/effects'; import SagaTester from 'redux-saga-tester'; chai.use(chaiAsPromised); const someValue = 'SOME_VALUE'; const someResult = 'SOME_RESULT'; const someOtherValue = 'SOME_OTHER_VALUE'; const middlewareMeta = 'MIDDLEWARE_TEST'; const fetchRequestActionType = 'FETCH_REQUEST' const fetchSuccessActionType = 'FETCH_SUCCESS' const initialState = { someKey : someValue }; const reducer = (state = someValue, action) => action.type === fetchSuccessActionType ? someOtherValue : state; const middleware = store => next => action => next({ ...action, meta : middlewareMeta }); // options are passed to createSagaMiddleware const options = { onError => console.error.bind(console) } const fetchApi = () => someResult; const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms)) function* listenAndFetch() { yield take(fetchRequestActionType); const result = yield call(fetchApi); yield call(delay, 500); // For async example. yield put({ type : fetchSuccessActionType, payload : result }); } it('Showcases the tester API', async () => { // Start up the saga tester const sagaTester = new SagaTester({ initialState, reducers : { someKey : reducer }, middlewares : [middleware], options, }); sagaTester.start(listenAndFetch); // Check that state was populated with initialState expect(sagaTester.getState()).to.deep.equal(initialState); // Dispatch the event to start the saga sagaTester.dispatch({type : fetchRequestActionType}); // Hook into the success action await sagaTester.waitFor(fetchSuccessActionType); // Check that all actions have the meta property from the middleware sagaTester.getCalledActions().forEach(action => { expect(action.meta).to.equal(middlewareMeta) }); // Check that the new state was affected by the reducer expect(sagaTester.getState()).to.deep.equal({ someKey : someOtherValue }); // Check that the saga listens only once sagaTester.dispatch({ type : fetchRequestActionType }); expect(sagaTester.numCalled(fetchRequestActionType)).to.equal(2); expect(sagaTester.numCalled(fetchSuccessActionType)).to.equal(1); // Reset the state and action list, dispatch again // and check that it was called sagaTester.reset(true); expect(sagaTester.wasCalled(fetchRequestActionType)).to.equal(false); sagaTester.dispatch({ type : fetchRequestActionType }); expect(sagaTester.wasCalled(fetchRequestActionType)).to.equal(true); }) ``` -------------------------------- ### Test Sagas with HTTP Mocking using Nock (JavaScript) Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Illustrates how to test sagas that interact with external APIs by mocking HTTP requests using the `nock` library. This example shows setting up a mock API response for a GET request and verifying that the saga correctly processes the mocked data. ```javascript import { expect } from 'chai'; import { call, put, takeLatest } from 'redux-saga/effects'; import SagaTester from 'redux-saga-tester'; import fetch from 'node-fetch'; import nock from 'nock'; // Saga that fetches data from external API function* handleFetchUsers() { try { const response = yield call(fetch, 'https://api.example.com/users'); const users = yield call([response, 'json']); yield put({ type: 'FETCH_USERS_SUCCESS', payload: users }); } catch (error) { yield put({ type: 'FETCH_USERS_FAILURE', error: error.message }); } } function* usersSaga() { yield takeLatest('FETCH_USERS_REQUEST', handleFetchUsers); } async function testWithNock() { // Setup HTTP mock const mockUsers = [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' } ]; nock('https://api.example.com') .get('/users') .reply(200, mockUsers); // Create tester and start saga const sagaTester = new SagaTester(); sagaTester.start(usersSaga); // Trigger the fetch sagaTester.dispatch({ type: 'FETCH_USERS_REQUEST' }); // Wait for success const successAction = await sagaTester.waitFor('FETCH_USERS_SUCCESS'); // Verify the result expect(successAction).to.deep.equal({ type: 'FETCH_USERS_SUCCESS', payload: mockUsers }); expect(sagaTester.getLatestCalledAction()).to.deep.equal({ type: 'FETCH_USERS_SUCCESS', payload: mockUsers }); } testWithNock(); ``` -------------------------------- ### Start Saga Execution Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Initiates the execution of a given saga generator function. This method allows passing optional arguments to the saga when it starts. ```javascript sagaTester.start(saga, [...args]); // saga: Function (the generator function to start) // [...args]: Any (optional arguments to pass to the saga) ``` -------------------------------- ### Initialize SagaTester Instance with Configuration Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Initializes a new SagaTester instance with optional configuration. This includes setting initial state, providing reducers, defining middlewares, and configuring saga middleware options. It allows for a comprehensive setup of the Redux environment for testing sagas. ```javascript import SagaTester from 'redux-saga-tester'; // Basic initialization const sagaTester = new SagaTester({ initialState: { user: null, data: [] }, reducers: { user: (state = null, action) => action.type === 'LOGIN_SUCCESS' ? action.payload : state, data: (state = [], action) => action.type === 'FETCH_SUCCESS' ? action.payload : state }, middlewares: [ store => next => action => { console.log('Action:', action.type); return next(action); } ], combineReducers: customCombineReducers, // optional custom combineReducers function ignoreReduxActions: true, // default true, filters out @@redux/ actions from history options: { onError: (err) => console.error('Saga error:', err) // passed to createSagaMiddleware } }); // Get initial state const state = sagaTester.getState(); // Returns: { user: null, data: [] } ``` -------------------------------- ### Start a Saga Generator Function with Arguments Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Starts the execution of a saga generator function within the SagaTester environment. Optional arguments can be passed directly to the saga function, allowing for parameterized saga execution during testing. This is crucial for testing sagas that depend on external configurations or data. ```javascript import { take, call, put } from 'redux-saga/effects'; // Define a saga function* watchUserLogin(apiEndpoint) { while (true) { const action = yield take('LOGIN_REQUEST'); try { const user = yield call(fetch, `${apiEndpoint}/login`, { method: 'POST', body: JSON.stringify(action.payload) }); const userData = yield call([user, 'json']); yield put({ type: 'LOGIN_SUCCESS', payload: userData }); } catch (error) { yield put({ type: 'LOGIN_FAILURE', error: error.message }); } } } // Start the saga with arguments const sagaTester = new SagaTester({ initialState: { user: null } }); sagaTester.start(watchUserLogin, 'https://api.example.com'); // Saga is now running and listening for LOGIN_REQUEST actions ``` -------------------------------- ### Get All Dispatched Actions Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Returns an array containing all actions that have been dispatched to the store since the SagaTester was initialized or last reset. ```javascript const allActions = sagaTester.getCalledActions(); // Returns: Array[Actions] ``` -------------------------------- ### Get and Update State in Redux Saga Tests (JavaScript) Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Demonstrates how to access the current Redux store state and update it programmatically within tests using redux-saga-tester. It covers using `getState()` to retrieve the state and `dispatch()` to modify it via reducers, as well as `updateState()` for direct state manipulation when using a default reducer. ```javascript import SagaTester from 'redux-saga-tester'; import { takeEvery, select, put } from 'redux-saga/effects'; const counterReducer = (state = { count: 0 }, action) => { switch (action.type) { case 'INCREMENT': return { count: state.count + 1 }; case 'DECREMENT': return { count: state.count - 1 }; default: return state; } }; function* incrementIfEven() { const state = yield select(); if (state.counter.count % 2 === 0) { yield put({ type: 'INCREMENT' }); } } function* rootSaga() { yield takeEvery('CHECK_AND_INCREMENT', incrementIfEven); } const sagaTester = new SagaTester({ initialState: { counter: { count: 0 } }, reducers: { counter: counterReducer } }); sagaTester.start(rootSaga); // Get current state console.log(sagaTester.getState()); // Returns: { counter: { count: 0 } } // Dispatch action that modifies state sagaTester.dispatch({ type: 'INCREMENT' }); console.log(sagaTester.getState()); // Returns: { counter: { count: 1 } } // Update state directly (only works with default reducer) const simpleTester = new SagaTester({ initialState: { user: null, tokens: 0 } }); simpleTester.updateState({ tokens: 100 }); console.log(simpleTester.getState()); // Returns: { user: null, tokens: 100 } ``` -------------------------------- ### Retrieving Dispatched Actions in Redux-Saga Tester Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt This snippet demonstrates how to retrieve the history of all dispatched actions using `getCalledActions`. It also shows how to get the most recent action with `getLatestCalledAction` and the last N actions with `getLatestCalledActions`. ```javascript import SagaTester from 'redux-saga-tester'; import { takeEvery, put } from 'redux-saga/effects'; function* handleAction() { yield put({ type: 'STEP_1', timestamp: Date.now() }); yield put({ type: 'STEP_2', timestamp: Date.now() }); yield put({ type: 'STEP_3', timestamp: Date.now() }); } function* rootSaga() { yield takeEvery('START', handleAction); } const sagaTester = new SagaTester(); sagaTester.start(rootSaga); sagaTester.dispatch({ type: 'START' }); sagaTester.dispatch({ type: 'MANUAL_ACTION', data: 'test' }); // Get all called actions const allActions = sagaTester.getCalledActions(); console.log(allActions); // Returns: [ // { type: 'START' }, // { type: 'STEP_1', timestamp: 1234567890 }, // { type: 'STEP_2', timestamp: 1234567891 }, // { type: 'STEP_3', timestamp: 1234567892 }, // { type: 'MANUAL_ACTION', data: 'test' } // ] // Get latest action const latestAction = sagaTester.getLatestCalledAction(); console.log(latestAction); // Returns: { type: 'MANUAL_ACTION', data: 'test' } // Get last N actions const lastThree = sagaTester.getLatestCalledActions(3); console.log(lastThree); // Returns: [ // { type: 'STEP_3', timestamp: 1234567892 }, // { type: 'MANUAL_ACTION', data: 'test' } // ] ``` -------------------------------- ### Get Current Store State Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Retrieves the current state of the Redux store. This is useful for asserting the state after certain actions or saga effects have occurred. ```javascript const currentState = sagaTester.getState(); // Returns: Object (the current state of the Redux store) ``` -------------------------------- ### Get Latest Dispatched Action Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Retrieves the most recently dispatched action to the Redux store. This is helpful for inspecting the immediate preceding action. ```javascript const latestAction = sagaTester.getLatestCalledAction(); // Returns: Action (the last action dispatched) ``` -------------------------------- ### Initialize SagaTester Instance Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Creates a new instance of SagaTester, which is used to test Redux-Saga logic. It accepts an options object for configuring the initial state, reducers, and other middleware settings. ```javascript const sagaTester = new SagaTester(options); // options can include: // initialState: Object // reducers: Object | Function // middlewares: Array[Function] // combineReducers: Function // ignoreReduxActions: Boolean ``` -------------------------------- ### Dispatch Action to Store Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Dispatches a Redux action to the store managed by SagaTester. This is crucial for triggering sagas or updating the state. ```javascript sagaTester.dispatch(action); // action: Object (the Redux action object to dispatch) ``` -------------------------------- ### Dispatch Actions to Trigger Sagas and State Changes Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Dispatches actions to the Redux store managed by SagaTester. This simulates user interactions or external events, triggering saga execution and subsequent state updates. It's a core method for testing the flow and effects of sagas in response to dispatched actions. ```javascript import SagaTester from 'redux-saga-tester'; import { takeLatest, call, put } from 'redux-saga/effects'; // Mock API function const fetchUserData = (userId) => Promise.resolve({ id: userId, name: 'John Doe', email: 'john@example.com' }); function* handleFetchUser(action) { try { const user = yield call(fetchUserData, action.payload.userId); yield put({ type: 'FETCH_USER_SUCCESS', payload: user }); } catch (error) { yield put({ type: 'FETCH_USER_FAILURE', error: error.message }); } } function* userSaga() { yield takeLatest('FETCH_USER_REQUEST', handleFetchUser); } const sagaTester = new SagaTester(); sagaTester.start(userSaga); // Dispatch action sagaTester.dispatch({ type: 'FETCH_USER_REQUEST', payload: { userId: 123 } }); // Action is now processed by the saga ``` -------------------------------- ### Test Multi-Step Async Action Sequences with redux-saga-tester Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Illustrates how to test sagas that involve a sequence of asynchronous operations and dispatch multiple actions over time. This snippet utilizes SagaTester's ability to wait for specific actions in order, including using the `futureOnly` option to differentiate between repeated actions. It verifies the correct sequencing and payload of each step in a multi-stage process. ```javascript import { expect } from 'chai'; import { call, put, takeEvery, delay } from 'redux-saga/effects'; import SagaTester from 'redux-saga-tester'; const processStep = (step) => Promise.resolve({ step, data: `Data for step ${step}` }); function* handleMultiStepProcess() { yield put({ type: 'PROCESS_STARTED' }); const step1 = yield call(processStep, 1); yield put({ type: 'STEP_COMPLETE', payload: step1 }); yield delay(100); const step2 = yield call(processStep, 2); yield put({ type: 'STEP_COMPLETE', payload: step2 }); yield delay(100); const step3 = yield call(processStep, 3); yield put({ type: 'STEP_COMPLETE', payload: step3 }); yield put({ type: 'PROCESS_FINISHED' }); } function* processSaga() { yield takeEvery('START_PROCESS', handleMultiStepProcess); } async function testMultiStep() { const sagaTester = new SagaTester(); sagaTester.start(processSaga); // Start the process sagaTester.dispatch({ type: 'START_PROCESS' }); // Wait for first step await sagaTester.waitFor('PROCESS_STARTED'); const firstStepAction = await sagaTester.waitFor('STEP_COMPLETE'); expect(firstStepAction.payload).to.deep.equal({ step: 1, data: 'Data for step 1' }); // Wait for second step (use futureOnly to wait for next occurrence) const secondStepAction = await sagaTester.waitFor('STEP_COMPLETE', true); expect(secondStepAction.payload).to.deep.equal({ step: 2, data: 'Data for step 2' }); // Wait for third step const thirdStepAction = await sagaTester.waitFor('STEP_COMPLETE', true); expect(thirdStepAction.payload).to.deep.equal({ step: 3, data: 'Data for step 3' }); // Wait for completion await sagaTester.waitFor('PROCESS_FINISHED'); // Verify the complete sequence const allActions = sagaTester.getCalledActions(); expect(allActions.map(a => a.type)).to.deep.equal([ 'START_PROCESS', 'PROCESS_STARTED', 'STEP_COMPLETE', 'STEP_COMPLETE', 'STEP_COMPLETE', 'PROCESS_FINISHED' ]); } testMultiStep(); ``` -------------------------------- ### Test Debounced Sagas with takeLatest using redux-saga-tester Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Demonstrates how to test sagas that implement debouncing logic using the takeLatest effect. This snippet focuses on ensuring that only the latest dispatched action triggers the saga's effect after a delay, preventing race conditions and redundant calls. It utilizes SagaTester's dispatch and waitFor methods to simulate rapid action dispatching and assert the final outcome. ```javascript import { expect } from 'chai'; import { call, put, takeLatest, delay } from 'redux-saga/effects'; import SagaTester from 'redux-saga-tester'; const searchApi = (query) => Promise.resolve({ results: [`Result for ${query}`], count: 1 }); function* handleSearch(action) { // Debounce by 300ms yield delay(300); const results = yield call(searchApi, action.payload.query); yield put({ type: 'SEARCH_SUCCESS', payload: results }); } function* searchSaga() { // takeLatest will cancel previous handleSearch if new SEARCH_REQUEST comes yield takeLatest('SEARCH_REQUEST', handleSearch); } async function testDebouncedSearch() { const sagaTester = new SagaTester({ initialState: { results: [], isSearching: false } }); sagaTester.start(searchSaga); // Rapid-fire multiple search requests sagaTester.dispatch({ type: 'SEARCH_REQUEST', payload: { query: 'a' } }); sagaTester.dispatch({ type: 'SEARCH_REQUEST', payload: { query: 'ab' } }); sagaTester.dispatch({ type: 'SEARCH_REQUEST', payload: { query: 'abc' } }); // Wait for the success action const successAction = await sagaTester.waitFor('SEARCH_SUCCESS'); // Only the last search should complete expect(successAction.payload).to.deep.equal({ results: ['Result for abc'], count: 1 }); // Verify only one success action was dispatched expect(sagaTester.numCalled('SEARCH_REQUEST')).to.equal(3); expect(sagaTester.numCalled('SEARCH_SUCCESS')).to.equal(1); } testDebouncedSearch(); ``` -------------------------------- ### Waiting for Actions with waitFor in Redux-Saga Tester Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt This snippet demonstrates how to use the `waitFor` method to asynchronously wait for a specific action type to be dispatched. It returns a promise that resolves with the dispatched action object. The `waitFor` method can also be configured to only wait for future actions, ignoring those already dispatched. ```javascript import SagaTester from 'redux-saga-tester'; import { takeEvery, call, put, delay } from 'redux-saga/effects'; const fetchApi = () => ({ data: 'response data', timestamp: Date.now() }); function* handleRequest() { yield delay(100); // Simulate async work const result = yield call(fetchApi); yield put({ type: 'FETCH_SUCCESS', payload: result }); } function* rootSaga() { yield takeEvery('FETCH_REQUEST', handleRequest); } async function testSaga() { const sagaTester = new SagaTester({ initialState: { data: null } }); sagaTester.start(rootSaga); // Dispatch request sagaTester.dispatch({ type: 'FETCH_REQUEST' }); // Wait for success action - promise resolves when action is dispatched const successAction = await sagaTester.waitFor('FETCH_SUCCESS'); console.log(successAction); // Returns: { type: 'FETCH_SUCCESS', payload: { data: 'response data', timestamp: 1234567890 } } // Wait for future action only (ignores already dispatched actions) sagaTester.dispatch({ type: 'FETCH_REQUEST' }); const futureAction = await sagaTester.waitFor('FETCH_SUCCESS', true); console.log(futureAction); } testSaga(); ``` -------------------------------- ### Checking Action History with wasCalled and numCalled in Redux-Saga Tester Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt This snippet illustrates how to verify if specific actions have been dispatched and how many times they have occurred using `wasCalled` and `numCalled`. These methods are useful for asserting the behavior of sagas in response to dispatched actions. ```javascript import SagaTester from 'redux-saga-tester'; import { takeEvery, put } from 'redux-saga/effects'; function* handleMultipleActions(action) { yield put({ type: 'ACTION_A' }); yield put({ type: 'ACTION_B' }); yield put({ type: 'ACTION_A' }); } function* rootSaga() { yield takeEvery('TRIGGER', handleMultipleActions); } const sagaTester = new SagaTester(); sagaTester.start(rootSaga); // Check before any actions console.log(sagaTester.wasCalled('ACTION_A')); // false console.log(sagaTester.numCalled('ACTION_A')); // 0 sagaTester.dispatch({ type: 'TRIGGER' }); // Check after dispatch console.log(sagaTester.wasCalled('ACTION_A')); // true console.log(sagaTester.numCalled('ACTION_A')); // 2 console.log(sagaTester.wasCalled('ACTION_B')); // true console.log(sagaTester.numCalled('ACTION_B')); // 1 console.log(sagaTester.wasCalled('ACTION_C')); // false console.log(sagaTester.numCalled('ACTION_C')); // 0 ``` -------------------------------- ### Reset Redux Saga Tester State (JavaScript) Source: https://context7.com/wix-incubator/redux-saga-tester/llms.txt Explains how to reset the Redux store state back to its initial configuration and optionally clear the action history using `reset()` method of `redux-saga-tester`. This is crucial for ensuring test isolation between different test cases. ```javascript import SagaTester from 'redux-saga-tester'; import { takeEvery, put } from 'redux-saga/effects'; function* handleAction() { yield put({ type: 'PROCESSED' }); } function* rootSaga() { yield takeEvery('ACTION', handleAction); } const initialState = { count: 0, data: null }; const reducer = (state = initialState, action) => { switch (action.type) { case 'INCREMENT': return { ...state, count: state.count + 1 }; case 'SET_DATA': return { ...state, data: action.payload }; default: return state; } }; const sagaTester = new SagaTester({ initialState, reducers: { root: reducer } }); sagaTester.start(rootSaga); // Dispatch some actions and modify state sagaTester.dispatch({ type: 'INCREMENT' }); sagaTester.dispatch({ type: 'SET_DATA', payload: 'test data' }); sagaTester.dispatch({ type: 'ACTION' }); console.log(sagaTester.getState()); console.log(sagaTester.getCalledActions().length); // 4 actions console.log(sagaTester.wasCalled('PROCESSED')); // true // Reset state but keep action history sagaTester.reset(false); console.log(sagaTester.getState()); // Back to initialState console.log(sagaTester.getCalledActions().length); // Still 4 actions console.log(sagaTester.wasCalled('PROCESSED')); // Still true // Reset state and clear action history sagaTester.reset(true); console.log(sagaTester.getState()); // Back to initialState console.log(sagaTester.getCalledActions().length); // 0 actions console.log(sagaTester.wasCalled('PROCESSED')); // false ``` -------------------------------- ### Count Number of Times Action Was Called Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Returns the total number of times an action with the given type has been dispatched to the store. Useful for verifying repetitive actions. ```javascript const count = sagaTester.numCalled(actionType); // actionType: String (the type of action to count) // Returns: Number ``` -------------------------------- ### Wait for Specific Action Type Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Returns a Promise that resolves when an action of a specified type is dispatched. It can be configured to only resolve for future actions. ```javascript sagaTester.waitFor(actionType, futureOnly); // actionType: String (the type of action to wait for) // futureOnly: Boolean (if true, only resolves for actions dispatched after waitFor is called) // Returns: Promise ``` -------------------------------- ### Reset SagaTester State Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Resets the store's state back to its initial configuration. Optionally, it can also clear the history of dispatched actions. ```javascript sagaTester.reset(clearActionList); // clearActionList: Boolean (optional, defaults to false. If true, clears action history.) ``` -------------------------------- ### Update Store State Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Directly updates the state of the Redux store with a new state object. Note that this functionality is primarily intended for use with the default reducer configuration. ```javascript sagaTester.updateState(newState); // newState: Object (the new state to apply to the store) ``` -------------------------------- ### Check if Action Type Was Called Source: https://github.com/wix-incubator/redux-saga-tester/blob/master/README.md Determines whether an action with the specified type has been dispatched at least once. This is a simple boolean check for past dispatches. ```javascript const wasDispatched = sagaTester.wasCalled(actionType); // actionType: String (the type of action to check) // Returns: Boolean ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.