github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/packages/pyroscope-flamegraph/setupAfterEnv.ts (about)

     1  import '@testing-library/jest-dom';
     2  import 'jest-canvas-mock';
     3  import { configureToMatchImageSnapshot } from 'jest-image-snapshot';
     4  import type { MatchImageSnapshotOptions } from 'jest-image-snapshot';
     5  import 'regenerator-runtime/runtime';
     6  
     7  // TODO: maybe we don't need this file?
     8  expect.extend({
     9    toMatchImageSnapshot(received: string, options: MatchImageSnapshotOptions) {
    10      // If these checks pass, assume we're in a JSDOM environment with the 'canvas' package.
    11      if (process.env.RUN_SNAPSHOTS) {
    12        const customConfig = { threshold: 0.02 };
    13        const toMatchImageSnapshot = configureToMatchImageSnapshot({
    14          customDiffConfig: customConfig,
    15        }) as any;
    16  
    17        // TODO
    18        // for some reason it fails with
    19        // Expected 1 arguments, but got 3.
    20        // hence the any
    21        return toMatchImageSnapshot.call(this, received, options);
    22      }
    23  
    24      return {
    25        pass: true,
    26        message: () =>
    27          `Skipping 'toMatchImageSnapshot' assertion since env var 'RUN_SNAPSHOTS' is not set.`,
    28      };
    29    },
    30  });