How to use the tdd-buffet/expect/chai.expect function in tdd-buffet

To help you get started, we’ve selected a few tdd-buffet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NiGhTTraX / mugshot / tests / gui / suite.ts View on Github external
export async function expectIdenticalScreenshots(
  screenshot: Buffer | string,
  baselineName: string,
  message?: string
) {
  const baseline = await fs.readFile(
    path.join(__dirname, `screenshots/${BROWSER}/${baselineName}.png`)
  );

  if (typeof screenshot === 'string') {
    // eslint-disable-next-line no-param-reassign
    screenshot = await fs.readFile(screenshot);
  }

  const differ = new PixelDiffer({ threshold: 0 });
  expect((await differ.compare(baseline, screenshot)).matches, message).to.be
    .true;
}
github NiGhTTraX / mugshot / tests / node / suite.ts View on Github external
export async function expectIdenticalBuffers(actual: Buffer, expected: Buffer) {
  const screenshotJimp = await Jimp.read(actual);
  const baselineJimp = await Jimp.read(expected);

  const sWidth = screenshotJimp.getWidth();
  const sHeight = screenshotJimp.getHeight();
  const bWidth = baselineJimp.getWidth();
  const bHeight = baselineJimp.getHeight();

  expect(sWidth, 'Images have different widths').to.equal(bWidth);
  expect(bHeight, 'Images have different heights').to.equal(bHeight);

  for (let x = 0; x < sWidth; x++) {
    for (let y = 0; y < sHeight; y++) {
      expect(
        Jimp.intToRGBA(screenshotJimp.getPixelColor(x, y)),
        `Pixel at ${x}, ${y} has a different color`
      ).to.deep.equal(Jimp.intToRGBA(baselineJimp.getPixelColor(x, y)));
    }
  }
}
github NiGhTTraX / mugshot / tests / node / suite.ts View on Github external
export async function expectIdenticalBuffers(actual: Buffer, expected: Buffer) {
  const screenshotJimp = await Jimp.read(actual);
  const baselineJimp = await Jimp.read(expected);

  const sWidth = screenshotJimp.getWidth();
  const sHeight = screenshotJimp.getHeight();
  const bWidth = baselineJimp.getWidth();
  const bHeight = baselineJimp.getHeight();

  expect(sWidth, 'Images have different widths').to.equal(bWidth);
  expect(bHeight, 'Images have different heights').to.equal(bHeight);

  for (let x = 0; x < sWidth; x++) {
    for (let y = 0; y < sHeight; y++) {
      expect(
        Jimp.intToRGBA(screenshotJimp.getPixelColor(x, y)),
        `Pixel at ${x}, ${y} has a different color`
      ).to.deep.equal(Jimp.intToRGBA(baselineJimp.getPixelColor(x, y)));
    }
  }
}
github NiGhTTraX / mugshot / tests / node / suite.ts View on Github external
export async function expectIdenticalBuffers(actual: Buffer, expected: Buffer) {
  const screenshotJimp = await Jimp.read(actual);
  const baselineJimp = await Jimp.read(expected);

  const sWidth = screenshotJimp.getWidth();
  const sHeight = screenshotJimp.getHeight();
  const bWidth = baselineJimp.getWidth();
  const bHeight = baselineJimp.getHeight();

  expect(sWidth, 'Images have different widths').to.equal(bWidth);
  expect(bHeight, 'Images have different heights').to.equal(bHeight);

  for (let x = 0; x < sWidth; x++) {
    for (let y = 0; y < sHeight; y++) {
      expect(
        Jimp.intToRGBA(screenshotJimp.getPixelColor(x, y)),
        `Pixel at ${x}, ${y} has a different color`
      ).to.deep.equal(Jimp.intToRGBA(baselineJimp.getPixelColor(x, y)));
    }
  }
}

tdd-buffet

All you can eat TDD tools and libraries

MIT
Latest version published 2 years ago

Package Health Score

40 / 100
Full package analysis