summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/asserts.ts2
-rw-r--r--testing/format.ts14
-rw-r--r--testing/mod.ts10
-rw-r--r--testing/pretty.ts2
4 files changed, 11 insertions, 17 deletions
diff --git a/testing/asserts.ts b/testing/asserts.ts
index a2583c22a..cbdaf3a94 100644
--- a/testing/asserts.ts
+++ b/testing/asserts.ts
@@ -183,7 +183,7 @@ export function assertArrayContains(
expected: unknown[],
msg?: string
): void {
- let missing = [];
+ let missing: unknown[] = [];
for (let i = 0; i < expected.length; i++) {
let found = false;
for (let j = 0; j < actual.length; j++) {
diff --git a/testing/format.ts b/testing/format.ts
index 8ed066eb0..af8391b23 100644
--- a/testing/format.ts
+++ b/testing/format.ts
@@ -525,16 +525,10 @@ const getConfig = (options: Options): Config => ({
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function format(val: any, options: Optional<Options> = {}): string {
- const opts = Object.keys(DEFAULT_OPTIONS).reduce(
- (acc: Options, k: keyof Options): unknown => {
- const opt = options[k];
- if (typeof opt === "undefined") {
- return { ...acc, [k]: DEFAULT_OPTIONS[k] };
- }
- return { ...acc, [k]: opt };
- },
- {}
- ) as Options;
+ const opts: Options = {
+ ...DEFAULT_OPTIONS,
+ ...options
+ };
const basicResult = printBasicValue(val, opts);
if (basicResult !== null) {
return basicResult;
diff --git a/testing/mod.ts b/testing/mod.ts
index fab8145e8..4ec241c20 100644
--- a/testing/mod.ts
+++ b/testing/mod.ts
@@ -54,7 +54,7 @@ interface TestStats {
interface TestResult {
name: string;
- error: Error;
+ error?: Error;
ok: boolean;
printed: boolean;
}
@@ -68,7 +68,7 @@ function createTestResults(tests: TestDefinition[]): TestResults {
return tests.reduce(
(acc: TestResults, { name }: TestDefinition, i: number): TestResults => {
acc.keys.set(name, i);
- acc.cases.set(i, { name, printed: false, ok: false, error: null });
+ acc.cases.set(i, { name, printed: false, ok: false, error: undefined });
return acc;
},
{ cases: new Map(), keys: new Map() }
@@ -114,11 +114,11 @@ function printResults(
}
function previousPrinted(name: string, results: TestResults): boolean {
- const curIndex: number = results.keys.get(name);
+ const curIndex: number = results.keys.get(name)!;
if (curIndex === 0) {
return true;
}
- return results.cases.get(curIndex - 1).printed;
+ return results.cases.get(curIndex - 1)!.printed;
}
async function createTestCase(
@@ -127,7 +127,7 @@ async function createTestCase(
exitOnFail: boolean,
{ fn, name }: TestDefinition
): Promise<void> {
- const result: TestResult = results.cases.get(results.keys.get(name));
+ const result: TestResult = results.cases.get(results.keys.get(name)!)!;
try {
await fn();
stats.passed++;
diff --git a/testing/pretty.ts b/testing/pretty.ts
index b2ab79d70..f471bd6fd 100644
--- a/testing/pretty.ts
+++ b/testing/pretty.ts
@@ -38,7 +38,7 @@ function createSign(diffType: DiffType): string {
}
function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] {
- const messages = [];
+ const messages: string[] = [];
messages.push("");
messages.push("");
messages.push(