Skip to main content
Module

x/unitest/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/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