Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
injector: Injector
): Transpiler & Disposable {
if (options.transpilers.length) {
return injector.injectClass(ChildProcessTranspiler);
} else {
return {
transpile(files: readonly File[]) {
return Promise.resolve(files);
},
dispose() {
// noop
}
};
}
}
transpilerFactory.inject = tokens(commonTokens.options, commonTokens.injector);
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { RunResult, RunStatus, TestRunner } from '@stryker-mutator/api/test_runner';
import LibWrapper from './LibWrapper';
import { MochaOptions } from './MochaOptions';
import { StrykerMochaReporter } from './StrykerMochaReporter';
import { evalGlobal, mochaOptionsKey } from './utils';
const DEFAULT_TEST_PATTERN = 'test/**/*.js';
export default class MochaTestRunner implements TestRunner {
private testFileNames: string[];
private readonly mochaOptions: MochaOptions;
public static inject = tokens(commonTokens.logger, commonTokens.sandboxFileNames, commonTokens.options);
constructor(private readonly log: Logger, private readonly allFileNames: readonly string[], options: StrykerOptions) {
this.mochaOptions = options[mochaOptionsKey];
this.additionalRequires();
StrykerMochaReporter.log = log;
}
public init(): void {
if (LibWrapper.handleFiles) {
this.log.debug("Mocha >= 6 detected. Using mocha's `handleFiles` to load files");
this.testFileNames = this.mocha6DiscoverFiles(LibWrapper.handleFiles);
} else {
this.log.debug('Mocha < 6 detected. Using custom logic to discover files');
this.testFileNames = this.legacyDiscoverFiles();
}
}
import { Config } from '@stryker-mutator/api/config';
import { LogLevel, MutationScoreThresholds, StrykerOptions, ALL_REPORT_TYPES } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { TestFramework } from '@stryker-mutator/api/test_framework';
import { StrykerError } from '@stryker-mutator/util';
import { coreTokens } from '../di';
export default class ConfigValidator {
private isValid = true;
public static inject = tokens(commonTokens.logger, commonTokens.options, coreTokens.testFramework);
constructor(
private readonly log: Logger,
private readonly options: Readonly,
private readonly testFramework: TestFramework | null
) {}
public validate() {
this.validateTestFramework();
this.validateThresholds();
this.validateMutator();
this.validateLogLevel('logLevel');
this.validateLogLevel('fileLogLevel');
this.validateTimeout();
this.validateIsNumber('maxConcurrentTestRunners', this.options.maxConcurrentTestRunners);
this.validateIsStringArray('plugins', this.options.plugins);
this.validateIsStringArray('reporters', this.options.reporters);
import * as path from 'path';
import { Location, Position, StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { MutantResult, MutantStatus, mutationTestReportSchema, Reporter } from '@stryker-mutator/api/report';
import { normalizeWhitespaces } from '@stryker-mutator/util';
import { coreTokens } from '../di';
import InputFileCollection from '../input/InputFileCollection';
export class MutationTestReportCalculator {
public static inject = tokens(coreTokens.reporter, commonTokens.options, coreTokens.inputFiles, commonTokens.logger);
constructor(
private readonly reporter: Required,
private readonly options: StrykerOptions,
private readonly inputFiles: InputFileCollection,
private readonly log: Logger
) {}
public report(results: readonly MutantResult[]) {
this.reporter.onMutationTestReportReady(this.mutationTestReport(results));
}
private mutationTestReport(results: readonly MutantResult[]): mutationTestReportSchema.MutationTestResult {
return {
files: this.toFileResults(results),
schemaVersion: '1.0',
*/
interface Timing {
/**
* The time that the test runner was actually executing tests in milliseconds.
*/
net: number;
/**
* the time that was spend not executing tests in milliseconds.
* So the time it took to start the test runner and to report the result.
*/
overhead: number;
}
export default class InitialTestExecutor {
public static inject = tokens(
commonTokens.options,
commonTokens.logger,
coreTokens.inputFiles,
coreTokens.testFramework,
coreTokens.timer,
coreTokens.loggingContext,
coreTokens.transpiler,
coreTokens.temporaryDirectory
);
constructor(
private readonly options: StrykerOptions,
private readonly log: Logger,
private readonly inputFiles: InputFileCollection,
private readonly testFramework: TestFramework | null,
private readonly timer: Timer,
private readonly loggingContext: LoggingClientContext,
import { StrykerOptions } from '@stryker-mutator/api/core';
import { isOK } from '../../utils/netUtils';
import { getEnvironmentVariable } from '../../utils/objectUtils';
import { dashboardReporterTokens } from './tokens';
import { Report } from './Report';
interface ReportResponseBody {
href: string;
}
const STRYKER_DASHBOARD_API_KEY = 'STRYKER_DASHBOARD_API_KEY';
export default class DashboardReporterClient {
public static inject = tokens(commonTokens.logger, dashboardReporterTokens.httpClient, commonTokens.options);
constructor(private readonly log: Logger, private readonly httpClient: HttpClient, private readonly options: StrykerOptions) {}
public async updateReport({
report,
projectName,
version,
moduleName
}: {
report: Report;
projectName: string;
version: string;
moduleName: string | undefined;
}): Promise {
const url = this.getPutUrl(projectName, version, moduleName);
const serializedBody = JSON.stringify(report);
this.log.info('PUT report to %s (~%s bytes)', url, serializedBody.length);
import * as path from 'path';
import { StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { MatchedMutant, MutantResult, mutationTestReportSchema, Reporter, ScoreResult, SourceFile } from '@stryker-mutator/api/report';
import { fsAsPromised } from '@stryker-mutator/util';
import { cleanFolder } from '../utils/fileUtils';
import StrictReporter from './StrictReporter';
const DEFAULT_BASE_FOLDER = 'reports/mutation/events';
export default class EventRecorderReporter implements StrictReporter {
public static readonly inject = tokens(commonTokens.logger, commonTokens.options);
private readonly allWork: Array> = [];
private readonly createBaseFolderTask: Promise;
private _baseFolder: string;
private index = 0;
constructor(private readonly log: Logger, private readonly options: StrykerOptions) {
this.createBaseFolderTask = cleanFolder(this.baseFolder);
}
private get baseFolder() {
if (!this._baseFolder) {
if (this.options.eventReporter && this.options.eventReporter.baseDir) {
this._baseFolder = this.options.eventReporter.baseDir;
this.log.debug(`Using configured output folder ${this._baseFolder}`);
} else {