Skip to content

Commit

Permalink
feat(tester): add defaultDoctestRunnerOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Sep 1, 2019
1 parent a022d17 commit 3bcf8ed
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/@power-doctest/tester/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,23 @@ export interface testOptions {
// if it is false and Each testOptions.state is "none", do not run the test
// Default: false
disableRunning: boolean;
// default values for doctestRunnerOptions
// It is override by test case's `doctestRunnerOptions`.
defaultDoctestRunnerOptions?: PowerDoctestRunnerOptions;
}


export function test(parsedCode: ParsedCode, oprions?: testOptions): Promise<void> {
if (parsedCode.state === "disabled") {
return Promise.resolve();
}
if (oprions && oprions.disableRunning && parsedCode.state === "none") {
return Promise.resolve();
}
return run(parsedCode.code, parsedCode.doctestOptions).catch(error => {
return run(parsedCode.code, {
...(oprions && oprions.defaultDoctestRunnerOptions ? oprions.defaultDoctestRunnerOptions : {}),
...parsedCode.doctestOptions
}).catch(error => {
// if it is expected error, resolve it
if (parsedCode.expectedError && error.name === parsedCode.expectedError) {
return Promise.resolve();
Expand Down

0 comments on commit 3bcf8ed

Please sign in to comment.