Skip to content
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

Adds Error message for when there are no screenshots #6773

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

diyaayay
Copy link
Contributor

Resolves #6772

Changes:

  • In test/unit/visual/visualTest.js if actual.length===0 added error handling to throw an Error indicating lack of screenshots or if the developer needs to wait for asynchronous tasks to complete before the test ends.

Screenshots of the change:

PR Checklist

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

Thanks for adding to these docs! I left a few suggestions on how it might be a bit clearer and more concise.

@@ -151,6 +151,12 @@ window.visualTest = function(
actual.push(myp5.get());
});


if (actual.length === 0) {
throw new Error('No screenshots were generated. Check if your test generates screenshots correctly.If the test includes asynchronous operations, ensure they complete before the test ends.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a space is missing here:

Suggested change
throw new Error('No screenshots were generated. Check if your test generates screenshots correctly.If the test includes asynchronous operations, ensure they complete before the test ends.');
throw new Error('No screenshots were generated. Check if your test generates screenshots correctly. If the test includes asynchronous operations, ensure they complete before the test ends.');



The visual test environment is set up to execute your commands sequentially rather than running a preload or draw function that you provide.
In continuous integration (CI) environments, it's crucial to keep tests running as quickly as possible. Running a full `preload/draw` cycle as in a regular p5.js sketch can significantly slow down the testing process.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not quite that the preload/draw cycle takes long, but we want to encourage the code to be as minimal as possible, which generally means not drawing multiple frames when just one will do, using a small canvas size, and only loading assets if required by the functionality being tested. We maybe don't have to capture all of that in this one sentence, but maybe we can rephrase slightly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a continuous integration (CI) environment, optimizing test speed is essential. It is advantageous to keep the code concise, avoid unnecessary frames, minimize canvas size, and load assets only when essential for the specific functionality under test.
@davepagurek Let me know if the above paragraph would make more sense or something else.


The visual test environment is set up to execute your commands sequentially rather than running a preload or draw function that you provide.
In continuous integration (CI) environments, it's crucial to keep tests running as quickly as possible. Running a full `preload/draw` cycle as in a regular p5.js sketch can significantly slow down the testing process.
When testing features like 3D model rendering, you might encounter scenarios where you need to load a model before performing assertions. Here's an example of how you can handle Sequential Command Execution and Asynchronous Operations in your visual tests:
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than saying "Sequential Command Execution and Asynchronous Operations", it might be simpler to mention something like, return a promise that resolves when you have finished everything you want to test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To address scenarios involving operations like 3D model rendering, consider returning a promise that resolves upon completing all the necessary tests, ensuring efficiency in your visual testing approach.
@davepagurek Does this make more sense? Do we need more modifications? Maybe remove mentioning 3D models?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of "3D model rendering" you could say "asynchronous 3D model loading"? Since a promise is only necessary for async things, which is mostly loading. Other than that, the rest looks good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Thanks that would make it much more clear. @davepagurek

@diyaayay
Copy link
Contributor Author

@davepagurek Let me know if we need to make further changes.

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

Thanks for making those changes, looks great!

@davepagurek davepagurek merged commit 4b255e2 into processing:main Feb 1, 2024
2 checks passed
@diyaayay diyaayay deleted the Error-Handling/visualTests branch February 2, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Error Handling for No Screenshots Generated in Visual Tests
2 participants