Skip to content

Adding Visual Test Report in Github Actions #7653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: dev-2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,28 @@ jobs:
env:
CI: true
- name: build and test
id: test
run: npm test
continue-on-error: true
env:
CI: true
- name: Generate Visual Test Report
if: always()
run: node visual-report.js
env:
CI: true
- name: Upload Visual Test Report
if: always()
uses: actions/upload-artifact@v4
with:
name: visual-test-report
path: test/unit/visual/visual-report.html
retention-days: 14
- name: report test coverage
if: steps.test.outcome == 'success'
run: bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
env:
CI: true
- name: fail job if tests failed
if: steps.test.outcome != 'success'
run: exit 1
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ yarn.lock
docs/data.json
analyzer/
preview/
__screenshots__/
__screenshots__/
actual-screenshots/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, didn't notice it before: for consistency with existing __screenshots__ could you rename actual-screnshots to something like __screenshots_actual, please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the __screenshots__ here are not of the visual tests as they are not in the .gitignore file and are present in the repo.
Though I will change the name of the folder to screenshots_actual if you wish.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you're right it's not comparable, no worries, please disregard

visual-report.html
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

7 changes: 7 additions & 0 deletions test/unit/visual/visualTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,15 @@ export function visualTest(
: [];

for (let i = 0; i < actual.length; i++) {
const flatName = name.replace(/\//g, '-');
const actualFilename = `../actual-screenshots/${flatName}-${i.toString().padStart(3, '0')}.png`;
if (expected[i]) {
const result = await checkMatch(actual[i], expected[i], myp5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea: Could the missing actual screenshots be potentially explained by some surprising behavior here? Ie, if you move writeImageFile(actualFilename, toBase64(actual[i])); to above 446, does the issue persist?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean moving it out of the if condition... am I right?
If so, tried that as well. Still the same issue.

// Always save the actual image before potentially throwing an error
writeImageFile(actualFilename, toBase64(actual[i]));
if (!result.ok) {
const diffFilename = `../actual-screenshots/${flatName}-${i.toString().padStart(3, '0')}-diff.png`;
writeImageFile(diffFilename, toBase64(result.diff));
throw new Error(
`Screenshots do not match! Expected:\n${toBase64(expected[i])}\n\nReceived:\n${toBase64(actual[i])}\n\nDiff:\n${toBase64(result.diff)}\n\n` +
'If this is unexpected, paste these URLs into your browser to inspect them.\n\n' +
Expand All @@ -452,6 +458,7 @@ export function visualTest(
}
} else {
writeImageFile(expectedFilenames[i], toBase64(actual[i]));
writeImageFile(actualFilename, toBase64(actual[i]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also minor: this looks like it might be an accidental duplicate since it's also on line 449

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was written because earlier the command was written in both if and else conditions. Now, I've moved writeImageFile(actualFilename, toBase64(actual[i])); outside the conditions

}
}
});
Expand Down
Loading