Skip to content

Commit e2c17d3

Browse files
authored
feat(testing): export assertions and colors (#108)
1 parent cee9fd7 commit e2c17d3

File tree

6 files changed

+7
-12
lines changed

6 files changed

+7
-12
lines changed

testing/assert.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "@std/assert"

testing/assert_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./assert.ts"

testing/colors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "@std/fmt/colors"

testing/colors_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./colors.ts"

testing/expect.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
// Imports
66
import { type Async, expect as _expect, type Expected, fn } from "@std/expect"
7-
import { assert, assertEquals, type AssertionError as _AssertionError, assertIsError, assertMatch, assertNotEquals, assertNotStrictEquals, assertObjectMatch, assertStrictEquals } from "@std/assert"
7+
import { assert, assertEquals, AssertionError, assertIsError, assertMatch, assertNotEquals, assertNotStrictEquals, assertObjectMatch, assertStrictEquals } from "@std/assert"
88
import type { Arg, Arrayable, callback, Nullable, record, TypeOf } from "@libs/typing"
99
import type { testing } from "./test.ts"
1010
import { STATUS_CODE as Status } from "@std/http/status"
@@ -337,16 +337,6 @@ export interface ExtendedExpected<IsAsync = false> extends Expected<IsAsync> {
337337
rejects: Async<ExtendedExpected<true>>
338338
}
339339

340-
/** Error thrown when an assertion fails. */
341-
let AssertionError: typeof _AssertionError
342-
343-
// AssertionError is not exported by `@std/expect` (and it differs from `@std/assert`) which is why we retrieve it this way
344-
try {
345-
_expect(null).toBe(true)
346-
} catch (error) {
347-
AssertionError = error.constructor
348-
}
349-
350340
/** Process callback and format result to match {@link Expected} result interface. */
351341
function process(not: boolean, evaluate: callback, message = ""): { message: () => string; pass: boolean } {
352342
let pass = true
@@ -729,4 +719,4 @@ export function reset(fn: any) {
729719
const expect = _expect as unknown as ((...args: Parameters<typeof _expect>) => ExtendedExpected) & { [K in keyof typeof _expect]: typeof _expect[K] }
730720

731721
export { AssertionError, expect, fn, Status }
732-
export type { _AssertionError, _expect, Arg, Arrayable, Async, callback, Expected, Nullable, record, TypeOf }
722+
export type { _expect, Arg, Arrayable, Async, callback, Expected, Nullable, record, TypeOf }

testing/mod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./test.ts"
2+
export * from "./assert.ts"
23
export * from "./expect.ts"
34
export * from "./permissions.ts"
45
export * from "./runtime.ts"

0 commit comments

Comments
 (0)