aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/newline-snapshot-serializer.ts
blob: adbd6741563406276668149150d5cd586b8e87b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
let prev: string;

// this does not work as intended
// see https://jestjs.io/docs/en/configuration#snapshotserializers-arraystring
export function print(val: string): string {
  return JSON.stringify(val);
}
export function test(val: string): boolean {
  if (['prBody', 'prTitle'].some((str) => str === prev)) {
    return typeof val === 'string' && val.includes('\n');
  }
  prev = val;
  return false;
}