-
Notifications
You must be signed in to change notification settings - Fork 286
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
Automated Visual Tests #501
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Manual Testing is a Drag
Currently, whenever we release
xeokit-sdk
, we need to manually spot-review the live examples on at least Chrome, Firefox, Safari, Android, iOS, OSX, Linux and Windows. Also, whenever we releasexeokit-gltf-to-xkt
orxeokit-xkt-utils
we also need to spot-review live examples for those as well.If we automate these reviews, then we can get the following benefits:
Note that we'll still need to do some manual testing for each release. To streamline that, we'll set aside a special set of manual test pages, with a test plan for a human to follow. As we add more automated tests, we'll gradually shift from predominantly manual testing to automated testing, while still employing a human to test the subtle things, such as scene navigation controls.
Percy
We'll use Percy for automated visual testing. Percy's visual test review workflow will give us more confidence in xeokit, while at the same time reducing the time taken to review GitHub pull requests.
Each time a somebody makes a pull request to one of our repositories, Percy will automatically run our suite of tests on their changes. Percy will then attach the test report to the request, and if any of the tests fail, Percy flags the PR as needing fixes before it can be merged.
Each of our tests is a single HTML page that contains a xeokit Viewer with a full-page canvas. The Viewer in each page is programmed to test a particular feature within xeokit and render the result to its canvas.
When running our tests, Percy will successively load each page into a headless browser, while saving a snapshot of each page to the test report. When snapshot images have changed since the last test run, Percy flags those changes for review.
A shown in the screenshot below, we review the changes at
percy.io
, which guides us through the snapshots that changed since the last run. Here we can accept the changes if they look OK to us, at which point we have a clean Percy build.We've wired up Percy for
xeokit-sdk
andxeokit-xkt-utils
, and the public test reports for those repos are now published at:Percy Setup for xeokit-sdk
Let's take a look at how we've set up visual testing for the
xeokit-sdk
repository.The file tree below shows the general structure of this repository.
We've added three things to support automated visual testing:
./tests
contains our visual test pages.snapshots.js
is the Percy script that runs our test pages../assets
contains our test models and metadata, shared between theexamples
andtests
directories.We've also installed
percy/script
andhttp-server
as npm dev dependencies inpackage.json
.A Percy Test Page
Shown below is one of the test pages for the
xeokit-sdk
repository. This page is namedloading_XKT.html
and lives in the./tests
directory at the root of the repository.Our example test page sets up a xeokit viewer, loads a BIM model into it, then calls
signalTestComplete
to notify the Percy test runner that it's ready to have its snapshot taken. That function is a little helper we created, that inserts a dummy element into the DOM, which the test runner detects.Percy Test Runner Script
Shown below is the test runner script for the
xeokit-sdk
repository. This script is named./snapshot.js
and lives at the root of the repository. Percy will execute this script to run our tests.Those
testPage
calls will process our test pages. Notice our example test page in that sequence, which we've truncated here for brevity. As the script processes each page, it loads the page into Percy's headless browser, then saves a snapshot of the page to the test report.Running the Tests Manually
With the
xeokit-sdk
repository integrated withpercy.io
, and having installedpercy/script
andhttp-server
as npm dev dependencies, we can run its visual test suite from the console. Only project admins can do that though, since they'll need the authorization token frompercy.io
.Viewing the Test Report
When Percy has run our tests, it publishes a public report at: https://percy.io/73524691/xeokit-sdk
The text was updated successfully, but these errors were encountered: