14 lines
815 B
TypeScript
14 lines
815 B
TypeScript
import { expect } from 'claude-code/testing'
|
|
|
|
// 讓只能 import 'claude-code/testing' 的測試沙箱,沿用 node:assert/strict 的寫法
|
|
const assert = Object.assign((v: unknown, msg?: string) => expect(v, msg).toBeTruthy(), {
|
|
ok: (v: unknown, msg?: string) => expect(v, msg).toBeTruthy(),
|
|
equal: (a: unknown, b: unknown, msg?: string) => expect(a, msg).toBe(b),
|
|
notEqual: (a: unknown, b: unknown, msg?: string) => expect(a, msg).not.toBe(b),
|
|
deepEqual: (a: unknown, b: unknown, msg?: string) => expect(a, msg).toEqual(b),
|
|
match: (s: string, re: RegExp, msg?: string) => expect(re.test(s), msg).toBe(true),
|
|
doesNotMatch: (s: string, re: RegExp, msg?: string) => expect(re.test(s), msg).toBe(false),
|
|
throws: (fn: () => unknown, msg?: string) => expect(fn, msg).toThrow(),
|
|
})
|
|
export default assert
|