Skip to content

Show an example of screen-diff-plugin usage for codeceptjs #1417

Closed Answered by baev
bulataleev asked this question in Questions & Support
Discussion options

You must be logged in to vote
  // Read the three files and encode to base64
  const expected = fs.readFileSync("expected.png", "base64");
  const actual = fs.readFileSync("actual.png", "base64");
  const diff = fs.readFileSync("diff.png", "base64");

  // Wrap into a JSON, encode as string
  const content = JSON.stringify({
    expected: `data:image/png;base64,${expected}`,
    actual: `data:image/png;base64,${actual}`,
    diff: `data:image/png;base64,${diff}`,
  });

  // Attach to the test report
  allure.attachment("Screenshot diff", content, "application/vnd.allure.image.diff");

You can use any library to generate the diff image. It should work as long as you use any images in a format supported by modern browsers.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by baev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1160 on September 14, 2021 16:01.