Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/unitest/matcher/to_include_repeated.ts>toIncludeRepeated

🃏 Deno-first universal unit testing framework
Latest
function toIncludeRepeated
import { toIncludeRepeated } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_include_repeated.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