Skip to content

Commit

Permalink
fix(mocha-runner): improve debug logging (#2925)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed May 27, 2021
1 parent d5eb07a commit ecc53ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/mocha-runner/src/mocha-adapter.ts
Expand Up @@ -38,7 +38,9 @@ export class MochaAdapter {
}

public async handleRequires(requires: string[]): Promise<unknown> {
this.log.trace('Resolving requires %s', requires);
if (LibWrapper.handleRequires) {
this.log.trace('Using `handleRequires`');
const rawRootHooks = await LibWrapper.handleRequires(requires);
if (rawRootHooks) {
if (LibWrapper.loadRootHooks) {
Expand All @@ -57,6 +59,7 @@ export class MochaAdapter {
return moduleName;
}
});
this.log.trace('Requiring %s manually', modulesToRequire);
modulesToRequire.forEach(LibWrapper.require);
}
return undefined;
Expand Down
9 changes: 5 additions & 4 deletions packages/mocha-runner/src/mocha-options-loader.ts
Expand Up @@ -35,7 +35,11 @@ export class MochaOptionsLoader {

public load(strykerOptions: MochaRunnerWithStrykerOptions): MochaOptions {
const mochaOptions = { ...strykerOptions.mochaOptions } as MochaOptions;
return { ...DEFAULT_MOCHA_OPTIONS, ...this.loadMochaOptions(mochaOptions), ...mochaOptions };
const options = { ...DEFAULT_MOCHA_OPTIONS, ...this.loadMochaOptions(mochaOptions), ...mochaOptions };
if (this.log.isDebugEnabled()) {
this.log.debug(`Loaded options: ${JSON.stringify(options, null, 2)}`);
}
return options;
}

private loadMochaOptions(overrides: MochaOptions) {
Expand All @@ -56,9 +60,6 @@ export class MochaOptionsLoader {
this.log.trace(`Mocha: ${LibWrapper.loadOptions!.name}([${args.map((arg) => `'${arg}'`).join(',')}]) => ${JSON.stringify(rawConfig)}`);
}
const options = filterConfig(rawConfig);
if (this.log.isDebugEnabled()) {
this.log.debug(`Loaded options: ${JSON.stringify(options, null, 2)}`);
}
return options;
}

Expand Down

0 comments on commit ecc53ee

Please sign in to comment.