_setup.ts 559 B

1234567891011121314
  1. import type { ExecutionContext } from 'ava';
  2. export function codeContains(t: ExecutionContext, actual: string, expected: RegExp | RegExp[] | string[] | string) {
  3. const expectedArray = Array.isArray(expected) ? expected : [expected];
  4. expectedArray.forEach(e => {
  5. t.true(
  6. typeof e === 'string' ? actual.includes(e) : e.test(actual),
  7. `The following expected code is missing from the actual content:\n` +
  8. `${e}\n\n` +
  9. `Actual content:\n` +
  10. `${actual}`,
  11. );
  12. });
  13. }