stryker-mutator / stryker-js

Mutation testing for JavaScript and friends
https://stryker-mutator.io
Apache License 2.0
2.58k stars 246 forks source link

Data structure modifications #3968

Open magwas opened 1 year ago

magwas commented 1 year ago

Is your feature request related to a problem? Please describe. Stryker is unable to generate mutants in code building data structures, e.g. a typical reducer.

Describe the solution you'd like When a data structure is built, some fields could be set to random values. Ideally all of them in different mutants.

Describe alternatives you've considered

Additional context

This needs the type information. Do stryker still have it in the mutator? If not, what would be the way to actually have it?

Stryker could not introduce any mutant in this code:

export function clearSelectedHeroTransition(
  state: AppState): AppState {
  return {
    ...state,
    componentstates: {
      ...state.componentstates,
      heroeditor: initialState.componentstates.heroeditor
    }
  };
}
nicojs commented 1 year ago

Hi @magwas 🙋‍♂️. Thanks for this issue!

What mutants would you want in your code example? Would these 2 work for you?

export function clearSelectedHeroTransition(
  state: AppState): AppState {
  return {
-    ...state,
    componentstates: {
      ...state.componentstates,
      heroeditor: initialState.componentstates.heroeditor
    }
  };
}
export function clearSelectedHeroTransition(
  state: AppState): AppState {
  return {
    ...state,
    componentstates: {
-      ...state.componentstates,
      heroeditor: initialState.componentstates.heroeditor
    }
  };
}

If so, then I think we should be able to mutate the SpreadElement here.

image

magwas commented 1 year ago

That would be a nice partial solution. I would like to see all lines mutated actually.

stale[bot] commented 6 months ago

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.