Skip to content

test: visual regression#394

Merged
nickofthyme merged 43 commits intoelastic:masterfrom
nickofthyme:tests/visual-regression
Oct 10, 2019
Merged

test: visual regression#394
nickofthyme merged 43 commits intoelastic:masterfrom
nickofthyme:tests/visual-regression

Conversation

@nickofthyme
Copy link
Copy Markdown
Collaborator

@nickofthyme nickofthyme commented Sep 26, 2019

Summary

closes #77

Visual regression tests and dependency upgrades

Add visual testing config

to run the integration tests just run. Don't forget to run yarn to get the latest deps.

yarn jest:integration

These tests are separate from the jest unit tests.

The following devDependencies were used:

Based on this example config/setup.

git ignores the screenshot diffs (i.e.**/__diff_output__/) as this seems to be a local use case. Any diffs created from CI are stored in gcs

Add seeded random number function

Please use the getRandomNumber function in stories/ and for *.test.ts{x} files (there is a lint rule to make sure 😏).

This allows for randomness in story data but allows us to control the randomness when we want, like in visual tests. This is controlled by using the RNG_SEED environment variable.

Visual regression tests use the 'elastic-charts' string add the RNG_SEED.

RNG_SEED='elastic-charts' yarn start

Upgraded devDependencies:

  • jest
  • typescript
  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • ts-jest
  • ts-loader

None of the upgrades create external breaking changes in the library


Note https://storybook.js.org/docs/testing/automated-visual-testing/#challenges

Prevent no-show charts here

Checklist

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • Unit tests were updated or added to match the most common scenarios
  • Each commit follows the convention

@nickofthyme nickofthyme added :test Missing or to be fixed test visual testing issues related to visual testing labels Sep 26, 2019
@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 26, 2019

Codecov Report

Merging #394 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
+ Coverage   97.95%   97.96%   +<.01%     
==========================================
  Files          39       39              
  Lines        2887     2899      +12     
  Branches      692      680      -12     
==========================================
+ Hits         2828     2840      +12     
  Misses         52       52              
  Partials        7        7
Impacted Files Coverage Δ
src/chart_types/xy_chart/utils/dimensions.ts 100% <100%> (ø) ⬆️
src/chart_types/xy_chart/utils/axis_utils.ts 100% <100%> (ø) ⬆️
src/utils/scales/scale_band.ts 94.87% <100%> (ø) ⬆️
.../chart_types/xy_chart/crosshair/crosshair_utils.ts 97.53% <100%> (ø) ⬆️
src/utils/bbox/canvas_text_bbox_calculator.ts 100% <100%> (ø) ⬆️
...chart_types/xy_chart/utils/stacked_series_utils.ts 97.5% <100%> (ø) ⬆️
src/chart_types/xy_chart/store/chart_state.ts 97.45% <100%> (ø) ⬆️
src/chart_types/xy_chart/utils/scales.ts 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7db45de...483603c. Read the comment docs.

@nickofthyme nickofthyme force-pushed the tests/visual-regression branch from fbf6919 to a198b70 Compare September 26, 2019 23:37
@markov00
Copy link
Copy Markdown
Collaborator

markov00 commented Sep 27, 2019

@nickofthyme thanks to starting this!
We started more or less the same a long time ago, but we stopped the process along the way.
One nice thing was kept from our previous work: we have a folder on our Jenkins CI where we can put all the diffs between the baseline and the current version.
This folder is then accessible from Jenkins Google Cloud Storage:
see

- google-cloud-storage:
credentials-id: kibana-ci-gcs-plugin
uploads:
- classic:
file-pattern: stories/__image_diff_snapshots__/**/*
storage-location: gs://kibana-ci-artifacts/jobs/$JOB_NAME/$BUILD_NUMBER
share-publicly: true
upload-for-failed-jobs: true
show-inline: true

I think it's enough to change the default diff storage to stories/__image_diff_snapshots__/**/*

@nickofthyme
Copy link
Copy Markdown
Collaborator Author

@markov00 Ok sweet I'll take a look at that! Thanks

@nickofthyme nickofthyme force-pushed the tests/visual-regression branch 3 times, most recently from 48cecd2 to b331814 Compare September 29, 2019 17:37
@nickofthyme
Copy link
Copy Markdown
Collaborator Author

Waiting to address lfs quota https://github.com/elastic/infra/issues/14886

@nickofthyme nickofthyme force-pushed the tests/visual-regression branch from 1edf75c to 426f1dc Compare October 1, 2019 15:49
@nickofthyme nickofthyme marked this pull request as ready for review October 3, 2019 14:41
Copy link
Copy Markdown
Collaborator

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

This looks great now, I've increased the server launch waiting time a bit as storybook can take a while before loading everything.
I think we can also go and remove the fonts so we don't depends on any particular fonts and we always use the fallback inside our docker container.

As next phase we can have some sort of html report or better a bot that push a comment on the PR with the diffs

@nickofthyme nickofthyme requested a review from markov00 October 10, 2019 13:21
Copy link
Copy Markdown
Collaborator

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

LGTM
please check the squash commit message and align the PR title to that

@nickofthyme nickofthyme merged commit 59c39bd into elastic:master Oct 10, 2019
@nickofthyme nickofthyme deleted the tests/visual-regression branch October 10, 2019 13:30
@nickofthyme nickofthyme changed the title tests: visual regression test: visual regression Oct 10, 2019
@markov00
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 13.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Issue released publicly :test Missing or to be fixed test visual testing issues related to visual testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual regression tests

3 participants