-
Notifications
You must be signed in to change notification settings - Fork 29
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
test(core): add visual regression testing #962
base: main
Are you sure you want to change the base?
Conversation
const screenshot = defineConfig({ | ||
test: { | ||
include: ['./img/visual-regression/*'], | ||
globals: true, | ||
environment: 'jsdom', | ||
threads: false, | ||
environmentOptions: { | ||
jsdom: { | ||
resources: 'usable' | ||
} | ||
} | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New config to be used only when yarn screenshot
is called so that only tests in img/visual-regression
will be run
<link rel="stylesheet" href="${baseUrl}/higlass@${higlassVersion}/dist/hglib.css"> | ||
<script src="${baseUrl}/react@${reactVersion}/umd/react.production.min.js"></script> | ||
<script src="${baseUrl}/react-dom@${reactVersion}/umd/react-dom.production.min.js"></script> | ||
<script src="${baseUrl}/pixi.js@${pixijsVersion}/dist/browser/pixi.min.js"></script> | ||
<script src="${baseUrl}/higlass@${higlassVersion}/dist/hglib.js"></script> | ||
<script type="text/javascript">${gosling}</script> | ||
<body> | ||
<div id="vis"></div> | ||
<script> | ||
gosling.embed(document.getElementById("vis"), JSON.parse(\`${spec}\`)) | ||
</script> | ||
</body> | ||
</html>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have to change when we update Gosling to only have a ESM build
Any updates on this? I think this will be quite useful when implementing performance related improvements. |
Thank you for the reminder! And, sorry, I lost track of this. Regarding the change of the axis, what do you think of making the visibility of ticks deterministic? We can remove the use of random values for determining the visibility, and it might be as simple as removing the following line:
|
## Visual Regression | ||
|
||
To test if your changes make a difference visually across a large number of specifications, you can use can use the `yarn screenshot` command. | ||
This command will use `dist/gosling.js` in a headless browser (using puppeteer) and take a screenshot of the visualization that is included in the editor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could briefly mention that one needs to run yarn build
before yarn screenshot
to test the updated Gosling.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add!
CONTRIBUTING.md
Outdated
|
||
To test if your changes make a difference visually across a large number of specifications, you can use can use the `yarn screenshot` command. | ||
This command will use `dist/gosling.js` in a headless browser (using puppeteer) and take a screenshot of the visualization that is included in the editor. | ||
It will save these screenshots in `img/visual-regression/new-screenshots`. If there is a difference compared to the screenshots in `img/visual-regression/screenshots` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, for now, would the usage pattern be like (occasionally) running the yarn build
and yarn screenshot
and then moving all files under img/visual-regression/new-screenshots
to img/visual-regression/screenshots
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how I currently see it being used in its current state, yes. I can add this as usage pattern in the documentation. I can also add a command which moves the screenshots from img/visual-regression/new-screenshots
to img/visual-regression/screenshots
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a very useful feature! Thank you for making these chnages.
One thing I notice is when I run yarn
, yarn build
, and yarn screenshot
, I am getting the following error complaining that the new-screenshots/*
are not found. Just in case it is related to wait times, I tested with larger values for related parameters, e.g., idelTime
, delay()
, but it shows the same issue. There must be something that I am missing. Do you have any clue about this issue?
Update: It looks like I needed to create empty |
Fix #958
Toward #
Adds a
yarn screenshot
command. This command will usedist/gosling.js
in a headless browser (using puppeteer) and take a screenshot of the visualization that is included in the editor. It will save these screenshots inimg/visual-regression/new-screenshots
. If there is a difference compared to the screenshots inimg/visual-regression/screenshots
it will show the differences in an image inimg/visual-regression/diffs
.Interestingly, the Gosling genomic axis is non-deterministic for many specs. Parts of the axis will look different between renders. This makes automated visual regression testing unsuitable. I think this best used as a check when testing locally to make sure that many visualizations are not impacted.
Checklist