UNPKG

@sgohlke/stryker-log-ignorer

Version:
28 lines (26 loc) 1.34 kB
import { PluginKind, commonTokens, declareFactoryPlugin, tokens } from "@stryker-mutator/api/plugin"; import fs from "node:fs"; //#region src/index.ts var LogIgnorer = class { static inject = [commonTokens.options]; options; constructor(options) { this.options = options?.logignore; } shouldIgnore(path) { const loggerObjectNames = this.options?.objectNames ?? ["console"]; if (path.isExpressionStatement() && path.node.expression.type === "CallExpression" && path.node.expression.callee.type === "MemberExpression" && path.node.expression.callee.object.type === "Identifier" && loggerObjectNames.includes(path.node.expression.callee.object.name)) return `We are not interested in testing ${loggerObjectNames} statements.`; } }; logIgnorerFactory.inject = tokens(commonTokens.injector); function logIgnorerFactory(injector) { return injector.injectClass(LogIgnorer); } function createLogIgnorerFactory() { return logIgnorerFactory; } const strykerPlugins = [declareFactoryPlugin(PluginKind.Ignore, "log-ignore", createLogIgnorerFactory())]; const strykerValidationSchema = JSON.parse(fs.readFileSync(new URL("../schema/log-ignorer-options.json", import.meta.url), "utf8")); //#endregion export { LogIgnorer, createLogIgnorerFactory, logIgnorerFactory, strykerPlugins, strykerValidationSchema }; //# sourceMappingURL=index.mjs.map