Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/unitest/matcher/mod.ts>toBeEmpty

๐Ÿƒ Deno-first universal unit testing framework
Latest
function toBeEmpty
Re-export
import { toBeEmpty } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/mod.ts";

Use .toBeEmpty when checking if a String '', Array [], Object {}, or Iterable is empty

import {
  defineExpect,
  test,
  toBeEmpty,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";

const expect = defineExpect({
  matcherMap: {
    toBeEmpty,
  },
});

test("passes when given an empty", () => {
  expect("").toBeEmpty();
  expect([]).toBeEmpty();
  expect({}).toBeEmpty();
  expect(new Map()).toBeEmpty();
});

Parameters

actual: Iterable<T> | Record<PropertyKey, unknown>