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 4 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__/
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

actual-screenshots/
visual-report.html
12 changes: 12 additions & 0 deletions test/unit/visual/cases/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ visualSuite("Typography", function () {
});
}
);
visualTest("intentionally failing test", function (p5, screenshot) {
p5.createCanvas(100, 100);
p5.background(255);
// initially put a red circle for storing in screenshots
p5.fill(255, 0, 0); // Red fill
p5.noStroke();

// Then change circle to rect to make it fail
p5.rect(30, 30, 40, 40);

screenshot();
});
});
}
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
7 changes: 7 additions & 0 deletions test/unit/visual/visualTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,16 @@
: [];

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(

Check failure on line 453 in test/unit/visual/visualTest.js

View workflow job for this annotation

GitHub Actions / test

test/unit/visual/cases/typography.js > Typography > textAlign > 2d mode > intentionally failing test > matches expected screenshots

Error: Screenshots do not match! Expected: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAYZJREFUaEPtWEsOAUEQfbO0ZmXtGpwBscVcgAM4gANwAZ+t4Axcw3pWrC1HikyEDEN9kkmnejv9quu9V91dPVGapikCGJETKZmL7kjJDIE74o4YKeClZSQsO6w7wpbOCOiOGAnLDuuOfJTuegU2G2C7BY5H4HJ5TK1WgVYL6HSAXg+oVNjq5wF1HVkugckESJLvSdbrwHQKDIdqZPSIjMfAfP5fYqMRMJv9h/kwW4cIh0SWkBIZOREqpziWqbpYiMtMRoQ2dqNRvCeKaNKeOZ1EB4CMyHoNDAZFaf72fbUC+v3f5ubMkhHpdoHdjr34C7DdFsWSEanVnveElA7dM+czO4qMSBSxF84FCn6xOZG7osGUFvVN+71OeVEs6s+YQ1ZawRy/wVyIVAZBtChZPQfRNErIKHW+lIJss7+fMEE8rDJS2VOXerDD4fWp22wC1J+V/qnLvAM0YLqlpZERM4YTYQpnBnNHzKRlBnZHmMKZwdwRM2mZgd0RpnBmMHfETFpm4GAcuQGBiSd69ar+HQAAAABJRU5ErkJggg== Received: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAKhJREFUaEPtl0sKwCAMRM39Dx2hdFmFSTog8rqOQzMvH43MzHHBFyRyGEWIHAZkQAQiJgcoLZOxZVmIlK0zHYSIydiyLEQe6yLKDn4ebLwoekRIZAESIqN5+6W0KK3llGRqsUd2K5Txy/h964M9wh5hj+zfG/QIPUKP/PsmN6r1br/GH1OlSUR1zB0PEbfDqj5EVMfc8RBxO6zqQ0R1zB0PEbfDqv41RCaB++9rN8XGIwAAAABJRU5ErkJggg== Diff: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAASBJREFUaEPtmFEOhCAMROEKeP8jyhXYgKwxLKRCQ+mS8WujVXbmDVi0IYRgNjgshCijCCLKgBgQAZFJDiBak4wdfiyIDFs36UYQmWTs8GNBJFln7a+DeVPg/Vl117njOl+51TB2FDwipZBgTEtAqSoJKsVoEOLPOgEq9O7IhGLhaiGjIr4ibzFLhXTEqUXnjtkyIca+nhNkxNIiMP75gDfZdxHivaeM7rrunOuqfxaziEBIw3cQiY0C5wMdoqUtWrFZettbUcvR1UziPcKbI6mN36JFyW38Hk1jDv+oGFVt/D2RO2KmdmP1FBN//9dWl1pTBa+z3uyC/5McCkJIi4QLQETYcHI4ECEtEi4AEWHDyeFAhLRIuABEhA0nh9uGyAdcLCF6npPVDQAAAABJRU5ErkJggg== If this is unexpected, paste these URLs into your browser to inspect them. If this change is expected, please delete the screenshots/Typography/textAlign/2d mode/intentionally failing test folder and run tests again to generate a new screenshot. ❯ test/unit/visual/visualTest.js:453:19

Check failure on line 453 in test/unit/visual/visualTest.js

View workflow job for this annotation

GitHub Actions / test

test/unit/visual/cases/typography.js > Typography > textAlign > webgl mode > intentionally failing test > matches expected screenshots

Error: Screenshots do not match! Expected: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAYZJREFUaEPtWEsOAUEQfbO0ZmXtGpwBscVcgAM4gANwAZ+t4Axcw3pWrC1HikyEDEN9kkmnejv9quu9V91dPVGapikCGJETKZmL7kjJDIE74o4YKeClZSQsO6w7wpbOCOiOGAnLDuuOfJTuegU2G2C7BY5H4HJ5TK1WgVYL6HSAXg+oVNjq5wF1HVkugckESJLvSdbrwHQKDIdqZPSIjMfAfP5fYqMRMJv9h/kwW4cIh0SWkBIZOREqpziWqbpYiMtMRoQ2dqNRvCeKaNKeOZ1EB4CMyHoNDAZFaf72fbUC+v3f5ubMkhHpdoHdjr34C7DdFsWSEanVnveElA7dM+czO4qMSBSxF84FCn6xOZG7osGUFvVN+71OeVEs6s+YQ1ZawRy/wVyIVAZBtChZPQfRNErIKHW+lIJss7+fMEE8rDJS2VOXerDD4fWp22wC1J+V/qnLvAM0YLqlpZERM4YTYQpnBnNHzKRlBnZHmMKZwdwRM2mZgd0RpnBmMHfETFpm4GAcuQGBiSd69ar+HQAAAABJRU5ErkJggg== Received: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAKhJREFUaEPtl0sKwCAMRM39Dx2hdFmFSTog8rqOQzMvH43MzHHBFyRyGEWIHAZkQAQiJgcoLZOxZVmIlK0zHYSIydiyLEQe6yLKDn4ebLwoekRIZAESIqN5+6W0KK3llGRqsUd2K5Txy/h964M9wh5hj+zfG/QIPUKP/PsmN6r1br/GH1OlSUR1zB0PEbfDqj5EVMfc8RBxO6zqQ0R1zB0PEbfDqv41RCaB++9rN8XGIwAAAABJRU5ErkJggg== Diff: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAASBJREFUaEPtmFEOhCAMROEKeP8jyhXYgKwxLKRCQ+mS8WujVXbmDVi0IYRgNjgshCijCCLKgBgQAZFJDiBak4wdfiyIDFs36UYQmWTs8GNBJFln7a+DeVPg/Vl117njOl+51TB2FDwipZBgTEtAqSoJKsVoEOLPOgEq9O7IhGLhaiGjIr4ibzFLhXTEqUXnjtkyIca+nhNkxNIiMP75gDfZdxHivaeM7rrunOuqfxaziEBIw3cQiY0C5wMdoqUtWrFZettbUcvR1UziPcKbI6mN36JFyW38Hk1jDv+oGFVt/D2RO2KmdmP1FBN//9dWl1pTBa+z3uyC/5McCkJIi4QLQETYcHI4ECEtEi4AEWHDyeFAhLRIuABEhA0nh9uGyAdcLCF6npPVDQAAAABJRU5ErkJggg== If this is unexpected, paste these URLs into your browser to inspect them. If this change is expected, please delete the screenshots/Typography/textAlign/webgl mode/intentionally failing test folder and run tests again to generate a new screenshot. ❯ test/unit/visual/visualTest.js:453:19
`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' +
`If this change is expected, please delete the screenshots/${name} folder and run tests again to generate a new screenshot.`,
Expand All @@ -452,6 +458,7 @@
}
} 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
Loading