Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to prevent using typed-redux-saga for tests #9

Open
krutoo opened this issue Dec 26, 2022 · 2 comments
Open

Ability to prevent using typed-redux-saga for tests #9

krutoo opened this issue Dec 26, 2022 · 2 comments

Comments

@krutoo
Copy link

krutoo commented Dec 26, 2022

Hi can you add option to forbid using typed-redux-saga and typed-redux-saga/macro?

Here is example of saga:

import { call } from 'typed-redux-saga/macro';

function saga() {
  yield* call(myFunction);
}

I want to use typed-redux-saga/macro only in source code of application and redux-saga/effects only in tests.

Bcause tests like this:

import { call } from 'typed-redux-saga/macro';
import { saga } from '../saga';

it('test', () => {
  const gen = saga();
  expect(gen.next().value).toEqual(call(myFunction));
});

are misleading.

In this case call effect are delegated by yield* and the correct check should be:

expect(gen.next().value).toEqual(call(myFunction).next().value);
@feidaZhang
Copy link

feidaZhang commented Jul 12, 2023

// jest.config
  transform: {
    '^.+\\.js(x)?$': 'babel-jest',
    '^.+\\.ts(x)?$': 'babel-jest',
    '^.+\\.ts(x)?$': [
      'ts-jest',
      {
        tsconfig: 'tsconfig.spec.json',
      },
    ],
  },


// ut 
import {testSaga} from 'redux-saga-test-plan';
import {initialRealm, initialSaga} from '~store/sagas/initial';

test('initialSaga', () => {
  testSaga(initialSaga).next().call(initialRealm).next().isDone();
});

@krutoo
Copy link
Author

krutoo commented Jul 12, 2023

@feidaZhang But in your example there is no eslint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants