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

Make expectSnapshot available in all functional test runs #82932

Merged
merged 24 commits into from
Nov 19, 2020

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Nov 9, 2020

Closes #80292.

Haven't figured out a way to test everything as jest-snapshot sidesteps mocking of fs, added some smoke tests where possible.

@dgieselaar dgieselaar force-pushed the snapshot-testing-ftr branch 3 times, most recently from 6f898b0 to f2adbb4 Compare November 9, 2020 10:56
@dgieselaar dgieselaar marked this pull request as ready for review November 9, 2020 12:42
@dgieselaar dgieselaar requested a review from a team as a code owner November 9, 2020 12:42
@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Nov 9, 2020
@dgieselaar
Copy link
Member Author

Hmm, I think I'll need some help with the types - looks like the Mocha types are conflicting with the Jest types.

Copy link
Contributor

@spalger spalger 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, I plan to run this and try it out in some test locally later today but the code looks great.

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Only thing I feel like I'm missing from this implementation of snapshots is the summary at the bottom of the test output that indicates how many snapshots were checked/failed/updated, etc. If you can produce some summary information that's tracked by the mocha reporter then you should be able to include information like that in the epilogue

@@ -141,6 +150,7 @@ export function runFtrCli() {
--exclude-tag=tag a tag to be excluded, pass multiple times for multiple tags
--test-stats print the number of tests (included and excluded) to STDERR
--updateBaselines replace baseline screenshots with whatever is generated from the test
--updateSnapshots replace inline and file snapshots with whatever is generated from the test
Copy link
Contributor

Choose a reason for hiding this comment

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

I definitely reached for the -u flag here, maybe it would be nice to have an --update,-u flag that sets both updateBaselines and updateSnapshots.

Copy link
Member Author

Choose a reason for hiding this comment

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

done - I tried to add -u only where necessary, but let me know if I missed anything.

x-pack/test/snapshot_declarations.d.ts Outdated Show resolved Hide resolved
@dgieselaar
Copy link
Member Author

@spalger I can't quite figure out how to collect stats. I'm not sure if I can get access to the reporter, or emit events that the reporter can use. Any clues where I should begin?

@dgieselaar
Copy link
Member Author

@spalger Looks like the typings in test/typings are not picked up in x-pack, is that correct or am I holding this wrong?

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -4,7 +4,7 @@
"tsBuildInfoFile": "../build/tsbuildinfo/test",
"types": ["node", "mocha", "flot"]
},
"include": ["**/*", "../typings/elastic__node_crypto.d.ts", "typings/**/*"],
"include": ["**/*", "../typings/elastic__node_crypto.d.ts", "typings/**/*", "../packages/kbn-test/types/ftr_globals/**/*"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Went ahead and unified the global mocha and snapshot types under this directory in @kbn/test and included them in both the test/tsconfig.json and x-pack/test/tsconfig.json projects.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dgieselaar
Copy link
Member Author

Thanks for all the help @spalger!

@dgieselaar dgieselaar merged commit 3a8ea29 into elastic:master Nov 19, 2020
@dgieselaar dgieselaar deleted the snapshot-testing-ftr branch November 19, 2020 07:38
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Nov 19, 2020
)

Co-authored-by: spalger <spalger@users.noreply.github.com>
# Conflicts:
#	packages/kbn-test/src/functional_test_runner/cli.ts
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 19, 2020
* master: (60 commits)
  Forward any registry cache-control header for files (elastic#83680)
  Revert "[Alerting] Add `alert.updatedAt` field to represent date of last user edit (elastic#83578)"
  [Security Solution][Detections] Fix adding an action to detection rules (elastic#83722)
  Make expectSnapshot available in all functional test runs (elastic#82932)
  Skip failing cypress test
  Increase bulk request timeout during esArchiver load (elastic#83657)
  [data.search] Server-side background session service (elastic#81099)
  [maps] convert VectorStyleEditor to TS (elastic#83582)
  Revert "[App Search] Engine overview layout stub (elastic#83504)"
  Adding documentation for global action configuration options (elastic#83557)
  [Metrics UI] Optimizations for Snapshot and Inventory Metadata (elastic#83596)
  chore(NA): update lmdb store to v0.8.15 (elastic#83726)
  [App Search] Engine overview layout stub (elastic#83504)
  [Workplace Search] Update SourceIcon to match latest changes in ent-search (elastic#83714)
  [Enterprise Search] Rename React Router helpers (elastic#83718)
  [Maps] Add 'crossed' & 'exited' events to tracking alert (elastic#82463)
  Updating code-owners to use new core/app-services team names (elastic#83731)
  Add Managed label to data streams and a view switch for the table (elastic#83049)
  [Maps] Add query bar inputs to geo threshold alerts tracked points & boundaries (elastic#80871)
  fix(NA): search examples kibana version declaration (elastic#83182)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 19, 2020
* master: (60 commits)
  Forward any registry cache-control header for files (elastic#83680)
  Revert "[Alerting] Add `alert.updatedAt` field to represent date of last user edit (elastic#83578)"
  [Security Solution][Detections] Fix adding an action to detection rules (elastic#83722)
  Make expectSnapshot available in all functional test runs (elastic#82932)
  Skip failing cypress test
  Increase bulk request timeout during esArchiver load (elastic#83657)
  [data.search] Server-side background session service (elastic#81099)
  [maps] convert VectorStyleEditor to TS (elastic#83582)
  Revert "[App Search] Engine overview layout stub (elastic#83504)"
  Adding documentation for global action configuration options (elastic#83557)
  [Metrics UI] Optimizations for Snapshot and Inventory Metadata (elastic#83596)
  chore(NA): update lmdb store to v0.8.15 (elastic#83726)
  [App Search] Engine overview layout stub (elastic#83504)
  [Workplace Search] Update SourceIcon to match latest changes in ent-search (elastic#83714)
  [Enterprise Search] Rename React Router helpers (elastic#83718)
  [Maps] Add 'crossed' & 'exited' events to tracking alert (elastic#82463)
  Updating code-owners to use new core/app-services team names (elastic#83731)
  Add Managed label to data streams and a view switch for the table (elastic#83049)
  [Maps] Add query bar inputs to geo threshold alerts tracked points & boundaries (elastic#80871)
  fix(NA): search examples kibana version declaration (elastic#83182)
  ...
phillipb added a commit to phillipb/kibana that referenced this pull request Nov 19, 2020
…ode-details

* 'master' of github.com:elastic/kibana:
  fixed pagination in connectors list (elastic#83638)
  Forward any registry cache-control header for files (elastic#83680)
  Revert "[Alerting] Add `alert.updatedAt` field to represent date of last user edit (elastic#83578)"
  [Security Solution][Detections] Fix adding an action to detection rules (elastic#83722)
  Make expectSnapshot available in all functional test runs (elastic#82932)
  Skip failing cypress test
  Increase bulk request timeout during esArchiver load (elastic#83657)
  [data.search] Server-side background session service (elastic#81099)
  [maps] convert VectorStyleEditor to TS (elastic#83582)
  Revert "[App Search] Engine overview layout stub (elastic#83504)"
  Adding documentation for global action configuration options (elastic#83557)
  [Metrics UI] Optimizations for Snapshot and Inventory Metadata (elastic#83596)
  chore(NA): update lmdb store to v0.8.15 (elastic#83726)
  [App Search] Engine overview layout stub (elastic#83504)
  [Workplace Search] Update SourceIcon to match latest changes in ent-search (elastic#83714)
  [Enterprise Search] Rename React Router helpers (elastic#83718)
dgieselaar added a commit that referenced this pull request Nov 19, 2020
Co-authored-by: spalger <spalger@users.noreply.github.com>
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Nov 19, 2020
)

Co-authored-by: spalger <spalger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Move expectSnapshot to @kbn/test
3 participants