diff options
Diffstat (limited to 'std/testing')
-rw-r--r-- | std/testing/format.ts | 6 | ||||
-rw-r--r-- | std/testing/mod.ts | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/std/testing/format.ts b/std/testing/format.ts index 953347c27..62fdde5eb 100644 --- a/std/testing/format.ts +++ b/std/testing/format.ts @@ -1,3 +1,5 @@ +import { assert } from "./asserts.ts"; + // This file is ported from pretty-format@24.0.0 /** * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. @@ -361,7 +363,9 @@ const getKeysOfEnumerableProperties = (object: {}): Array<string | symbol> => { if (Object.getOwnPropertySymbols) { Object.getOwnPropertySymbols(object).forEach((symbol): void => { - if (Object.getOwnPropertyDescriptor(object, symbol)!.enumerable) { + const d = Object.getOwnPropertyDescriptor(object, symbol); + assert(d != null); + if (d.enumerable) { keys.push(symbol); } }); diff --git a/std/testing/mod.ts b/std/testing/mod.ts index 16eae5ebe..a60e9c93f 100644 --- a/std/testing/mod.ts +++ b/std/testing/mod.ts @@ -261,11 +261,14 @@ function printResults( } function previousPrinted(name: string, results: TestResults): boolean { - const curIndex: number = results.keys.get(name)!; + const curIndex = results.keys.get(name); + assert(curIndex != null); if (curIndex === 0) { return true; } - return results.cases.get(curIndex - 1)!.printed; + const prev = results.cases.get(curIndex - 1); + assert(prev != null); + return prev.printed; } async function createTestCase( @@ -274,7 +277,10 @@ async function createTestCase( exitOnFail: boolean, { fn, name }: TestDefinition ): Promise<void> { - const result: TestResult = results.cases.get(results.keys.get(name)!)!; + const i = results.keys.get(name); + assert(i != null); + const result = results.cases.get(i); + assert(result != null); try { const start = performance.now(); await fn(); |