All files / testing / _testing / common.ts

100.00% Branches 0/0
100.00% Lines 4/4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
 
 
x58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
x58
x2820
x940

























// Imports
import type { Nullable, Promisable } from "@libs/typing"
export type { Nullable, Promisable }
import { highlight } from "../highlight.ts"

/** Test options. */
export type options = {
  permissions?: Deno.TestDefinition["permissions"]
  sanitizeResources?: Deno.TestDefinition["sanitizeResources"]
  sanitizeOps?: Deno.TestDefinition["sanitizeOps"]
  sanitizeExit?: Deno.TestDefinition["sanitizeExit"]
  env?: Record<string, string>
  [key: PropertyKey]: unknown
}

/** Test runner method. */
export type runner_method = (name: string, fn: () => Promisable<unknown>, options?: options) => Promisable<unknown>

/** Test runner. */
export type runner = runner_method & { only: runner_method; skip: runner_method; todo: runner_method }

/** Test runner mode. */
export type mode = "test" | "skip" | "only" | "todo"

/** Format test name. */
export function format(name: string): string {
  return highlight(name, { underline: true })
}