Skip to content
Merged
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,9 +24,23 @@ 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: generate TypeScript types
run: npm run generate-types
env:
Expand All @@ -36,6 +50,10 @@ jobs:
env:
CI: true
- 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
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ __screenshots__/
*.d.ts
p5.zip
yarn.lock

docs/data.json
analyzer/
preview/
__screenshots__/
actual-screenshots/
visual-report.html

todo.md

*.DS_Store
.idea
.project
.project

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 @@ -463,9 +463,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 @@ -474,6 +480,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
Loading