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

With typescript some of these mutations make no sense, or do they? Should I just ignore them? #5048

Open
kswope opened this issue Sep 29, 2024 · 6 comments
Labels
⁉ Question Further information is requested

Comments

@kswope
Copy link

kswope commented Sep 29, 2024

Here's a few mutations in very simple functions I'm having trouble with

(some output of stryker run)

[NoCoverage] BlockStatement
backend/src/test/dummies.ts:44:25
-   export function title() {
-     return chance.sentence()
-   }
+   export function title() {}

^ How would wiping out the entire function body ever be something I should account for in a test?

[Survived] ObjectLiteral
backend/src/test/dummies.ts:19:22
-     return chance.word({ length: 15 })
+     return chance.word({})

^ Passing hard coded parameters to a library function also doesn't seem like something that would be relevant to a test.

[Survived] StringLiteral
backend/src/dal/locations.ts:5:53
-   export async function create(userId: number, name = "default"): Promise<number> {
+   export async function create(userId: number, name = ""): Promise<number> {

^ This would make sense where string is used in a boolean context, but why would mutating a default argument make any sense?

@kswope kswope added the ⁉ Question Further information is requested label Sep 29, 2024
@nicojs
Copy link
Member

nicojs commented Sep 30, 2024

These mutations don't make sense indeed. If you want to filter them out, you should enable the TypeScript checker plugin

F.y.i. using the TypeScript checker is a tradeoff. On the one hand, mutants will be more accurate, on the other hand, it will take more time.

@kswope
Copy link
Author

kswope commented Oct 2, 2024

These mutations don't make sense indeed. If you want to filter them out, you should enable the TypeScript checker plugin

F.y.i. using the TypeScript checker is a tradeoff. On the one hand, mutants will be more accurate, on the other hand, it will take more time.

I got all those errors while using the typescript-checker.

@nicojs
Copy link
Member

nicojs commented Oct 2, 2024

Could you share your config and logging after running with --fileLogLevel trace?

@kswope
Copy link
Author

kswope commented Oct 2, 2024

// @ts-check
/** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */
const config = {
  _comment: "This config was generated using 'stryker init'.",
  testRunner: "vitest",
  mutate: ["*/**/!(*.test).ts"],
  // mutate: ["!backend/src/**/*.test.ts", "backend/src/**/dummies.ts"],
  reporters: ["progress", "clear-text", "html"],
  // mutator: {
  //   excludedMutations: ["ObjectLiteral", "BlockStatement", "StringLiteral"],
  // },
}
export default config

stryker.log

@nicojs
Copy link
Member

nicojs commented Oct 2, 2024

I can see you've installed the TypeScript checker, but you didn't configure it. Could try again?

// @ts-check
/** @type {import('@stryker-mutator/api/core').PartialStrykerOptions} */
const config = {
  _comment: "This config was generated using 'stryker init'.",
  testRunner: "vitest",
  mutate: ["*/**/!(*.test).ts"],
+ checkers: ["typescript"],
  // mutate: ["!backend/src/**/*.test.ts", "backend/src/**/dummies.ts"],
  reporters: ["progress", "clear-text", "html"],
  // mutator: {
  //   excludedMutations: ["ObjectLiteral", "BlockStatement", "StringLiteral"],
  // },
}
export default config

@kswope
Copy link
Author

kswope commented Oct 2, 2024

Somehow I got the impression from the docs that you only needed to load the plugin and not configure if you wanted something other than the default. So I copied the example config.

const config = {
  _comment: "This config was generated using 'stryker init'.",
  checkers: ["typescript"],
  tsconfigFile: "tsconfig.json",
  typescriptChecker: {
    prioritizePerformanceOverAccuracy: true,
  },
  testRunner: "vitest",
  mutate: ["*/**/!(*.test).ts"],
  // mutate: ["!backend/src/**/*.test.ts", "backend/src/**/dummies.ts"],
  reporters: ["progress", "clear-text", "html"],
  // mutator: {
  //   excludedMutations: ["ObjectLiteral", "BlockStatement", "StringLiteral"],
  // },
}
export default config

Nothing changed. I'm not sure what we are expecting since the code for that typescript plugin doesn't mention any of those mutations anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⁉ Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants