Skip to content

Commit

Permalink
fix(power-doctest): fix error Cannot access 'totalAssertionCount' bef…
Browse files Browse the repository at this point in the history
…ore initialization

> Uncaught ReferenceError: Cannot access 'totalAssertionCount' before initialization
  • Loading branch information
azu committed Jun 20, 2020
1 parent e4641aa commit 10b7e73
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/@power-doctest/tester/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ export function run(code: string, options: PowerDoctestRunnerOptions = {}): Prom
const timeout = options.timeout !== undefined ? options.timeout : 2000;
const postCallbackName = options.powerDoctestCallbackFunctionName || CALLBACK_FUNCTION_NAME;
const context = options.context || {};
// total count of assert
let totalAssertionCount = 0;
// current count of assert
let countOfExecutedAssertion = 0;
return new Promise((resolve, reject) => {
let isSettled = false;

const timeoutId = setTimeout(() => {
if (isSettled) {
return;
Expand Down Expand Up @@ -151,9 +156,9 @@ Also, you should consider to use { "runMode": "any" }`
filePath: filePath
});
// total count of assert
const totalAssertionCount = poweredCode.split(CALLBACK_FUNCTION_NAME).length - 1;
totalAssertionCount = poweredCode.split(CALLBACK_FUNCTION_NAME).length - 1;
// current count of assert
let countOfExecutedAssertion = 0;
countOfExecutedAssertion = 0;
const vm = new NodeVM({
console: options.console ? "inherit" : "off",
timeout: timeout,
Expand Down

0 comments on commit 10b7e73

Please sign in to comment.