Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
¿Cómo puedo probar redux .subscribe()

En mi código, que quiero probar, tiene la función store.subscribe(), y no sé cómo puedo probarlo.

 test('should call console.log inside subscribe fn', async () => { const store = configureStore(initialState); store.subscribe(() => console.log(store.getState())); // console.log was not called await wait(100); })

Y en mi código

 // index.ts export const store = createStore(); store.subscribe(() => console.log(store.getState())); // how can i test it in jest?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Desea probar la función de subscriber , luego puede activarla a través de la acción de envío. Afirmar el estado después de enviar cada acción.

 import { configureStore } from '@reduxjs/toolkit'; test('should call console.log inside subscribe fn', async () => { expect.assertions(1); const store = configureStore({ reducer: (state = 'test state') => state }); store.subscribe(() => { expect(store.getState()).toEqual('test state'); }); store.dispatch({ type: '' }); });

resultado de la prueba:

 PASS redux-toolkit-example packages/redux-toolkit-example/stackoverflow/69845750/index.test.ts ✓ should call console.log inside subscribe fn (4 ms) Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 3.869 s
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!