stryker-js
stryker-js copied to clipboard
Cannot mutation test the call of a redux reducer (Typescript)
I am trying to set up mutation testing for a project using react, redux and typescript
The tests run fine with jest. The stryker dry run fails due to
undefinedtests/com.kodekonveyor.reacttest.ui/registerPerson.test.ts:25:51 - error TS2349: This expression is not callable.
Not all constituents of type 'void | ActionCreatorWithOptionalPayload<Person, "/addPerson" | "testApp/addPerson">' are callable.
Type 'void' has no call signatures.
expect(dispatch).toHaveBeenCalledWith(actions.addPerson(formState))
actions.addPerson is defined by the following code:
const appState = createSlice({
name: 'testApp',
initialState: initialState,
reducers: {
addPerson: addPerson
},
})
export const actions = appState.actions
You can find the code at commit 7fdc9e330cd3fcb12fab90711504608cdca00eda of https://github.com/magwas/reacttest
It is small experimental code, not much more than needed to reproduce the error.
Stryker config
{
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"packageManager": "npm",
"reporters": [
"html",
"clear-text",
"progress"
],
"testRunner": "jest",
"coverageAnalysis": "perTest"
}
}
Test runner config
jest.config.js ''' /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { preset: 'ts-jest', testEnvironment: 'node', }; '''
Stryker environment
├── @stryker-mutator/[email protected]
├── @stryker-mutator/[email protected]
├── @stryker-mutator/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
Test runner environment
$ npm run test
> [email protected] test
> jest
PASS tests/com.kodekonveyor.reacttest.ui/registerPerson.test.ts
registerPerson
✓ prevents automatic redraw of the form (2 ms)
✓ adds the person from the form to the person list (1 ms)
✓ reinitializes the form data
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 2.486 s, estimated 5 s
Ran all test suites.
Your Environment
software | version(s) |
---|---|
node | v19.2.0 |
npm | 8.19.3 |
Operating System | Ubuntu jammy |
Add stryker.log
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.