🐛 Ensure core schemas are loaded before dependent snapshot schemas#431
Merged
🐛 Ensure core schemas are loaded before dependent snapshot schemas#431
Conversation
samarsault
pushed a commit
that referenced
this pull request
Mar 3, 2023
Bumps [cypress](https://github.com/cypress-io/cypress) from 8.7.0 to 9.0.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v8.7.0...v9.0.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
In tests, schemas are loaded where needed. In practice however, core schemas are not loaded in time for references in the snapshot schema. The answer is to register core schemas before they are needed, however by default this causes AJV to error about existing schema
$ids when core get's around to registering schemas for itself.The
addSchemautil was updated to replace existing$idschemas just as it already does for config file schemas. A test was added for this, but because the array handling was moved, coverage became low. Another test for an array of schemas was added to account for this missing coverage.Since arrays of schemas are handled by our util now rather than forwarded directly onto AJV, a new pattern was adopted in the appropriate places. Where multiple schemas are defined, the file exports a single
schemasarray that can be passed to theaddSchemacall made when registering schemas. This reduces some boilerplate around adding schemas and also makes it simple to add all possible required core schemas in one go before they are needed, which was the original intent of this PR.This will fix #429