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

x/unitest/matcher/mod.ts>toIncludeRepeated

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

Use .toIncludeRepeated when checking if a string includes the given string substring the correct number of times

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

const expect = defineExpect({
  matcherMap: {
    toIncludeRepeated,
  },
  modifierMap: {
    not,
  },
});

test("passes when value includes substring n times", () => {
  expect("hello hello world").toIncludeRepeated("hello", 2);
  expect("hello hello world").not.toIncludeRepeated("hello", 1);
});

Parameters

actual: string
substring: string
times: number