agiledigital / typed-redux-saga

An attempt to bring better TypeScript typing to redux-saga.
MIT License
315 stars 33 forks source link

Issue when using with redux-saga-test-plan #680

Closed aidin36 closed 1 year ago

aidin36 commented 1 year ago

When I use typed-redux-saga and redux-saga-test-plan, the all effect will be undefined and it fails to run the tests.

I've created a repo to reproduce the issue: https://github.com/aidin36/failing-typed-redux-saga-test-plan

If I replace the import from typed-redux-saga with redux-saga itself, it resolves the issue.

I'm using macro, and to my understanding, Babel should replace yield* all imported from typed-redux-saga with yield all imported from redux-saga before running the code. So there shouldn't be any issues!? Or am I doing something wrong?

I'm using node 18.12.1, on Ubuntu 22.10, and here's the full error:

Error log ``` console.error TypeError: Cannot read properties of undefined (reading 'all') at rootSaga$ (/home/aidin/workspace/testing/redux-saga-ts-jest/sagas.ts:9:10) at tryCatch (/home/aidin/workspace/testing/redux-saga-ts-jest/sagas.ts:9:1357) at Generator. (/home/aidin/workspace/testing/redux-saga-ts-jest/sagas.ts:9:4174) at Generator.next (/home/aidin/workspace/testing/redux-saga-ts-jest/sagas.ts:9:2208) at next (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1161:27) at proc (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1112:3) at /home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1371:16 at immediately (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:60:12) at runSaga (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1370:10) at Function.sagaMiddleware.run (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1427:25) at Object.run (/home/aidin/workspace/testing/redux-saga-ts-jest/index.tsx:13:16) at Runtime._execModule (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:1532:24) at Runtime._loadModule (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:1115:12) at Runtime.requireModule (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:975:12) at Runtime.requireModuleOrMock (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:1141:21) at Object. (/home/aidin/workspace/testing/redux-saga-ts-jest/sagas.unit.test.ts:3:1) at Runtime._execModule (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:1532:24) at Runtime._loadModule (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:1115:12) at Runtime.requireModule (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runtime/build/index.js:975:12) at jestAdapter (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:77:13) at processTicksAndRejections (node:internal/process/task_queues:95:5) at runTestInternal (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/aidin/workspace/testing/redux-saga-ts-jest/node_modules/jest-runner/build/runTest.js:444:34) ```
aidin36 commented 1 year ago

One of my teammates figured out that changing the jest transformation to the following would resolve the issue.

  transform: {
    '^.+\\.tsx?$': 'babel-jest',
  }

I'm closing the issue now.