@std/expect
Обзор
Этот модуль предоставляет совместимые с Jest функции для проверки утверждений с помощью expect.
import { expect } from "@std/expect";
const x = 6 * 7;
expect(x).toEqual(42);
expect(x).not.toEqual(0);
await expect(Promise.resolve(x)).resolves.toEqual(42);
В настоящее время модуль поддерживает следующие функции:
- Общие матчеры:
toBetoEqualtoStrictEqualtoMatchtoMatchObjecttoBeDefinedtoBeUndefinedtoBeNulltoBeNaNtoBeTruthytoBeFalsytoContaintoContainEqualtoHaveLengthtoBeGreaterThantoBeGreaterThanOrEqualtoBeLessThantoBeLessThanOrEqualtoBeCloseTotoBeInstanceOftoThrowtoHavePropertytoMatchSnapshottoMatchInlineSnapshot
- Матчеры для моков:
toHaveBeenCalledtoHaveBeenCalledTimestoHaveBeenCalledWithtoHaveBeenLastCalledWithtoHaveBeenNthCalledWithtoHaveReturnedtoHaveReturnedTimestoHaveReturnedWithtoHaveLastReturnedWithtoHaveNthReturnedWith
- Асимметричные матчеры:
- Утилиты:
expect.addSnapshotSerializerexpect.assertionsexpect.addEqualityTesterexpect.extendexpect.hasAssertions
Пока доступны не все функции:
- Матчеры:
toThrowErrorMatchingSnapshottoThrowErrorMatchingInlineSnapshot
За ходом добавления поддержки неподдерживаемых частей API можно следить в задаче.
Этот модуль во многом вдохновлён модулем x/expect, созданным Алленом Лалондом.
Добавление в проект
›_
deno add jsr:@std/expect
© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/std/expect