UNPKG

@sgohlke/stryker-log-ignorer

Version:
50 lines 1.47 kB
// src/index.ts import { PluginKind, commonTokens, declareFactoryPlugin, tokens } from "@stryker-mutator/api/plugin"; import fs from "fs"; 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; } var strykerPlugins = [ declareFactoryPlugin( PluginKind.Ignore, "log-ignore", createLogIgnorerFactory() ) ]; var strykerValidationSchema = JSON.parse( // eslint-disable-next-line security/detect-non-literal-fs-filename fs.readFileSync( new URL("../schema/log-ignorer-options.json", import.meta.url), "utf8" ) ); export { LogIgnorer, createLogIgnorerFactory, logIgnorerFactory, strykerPlugins, strykerValidationSchema }; //# sourceMappingURL=index.js.map