Skip to content

🐛 Ensure core schemas are loaded before dependent snapshot schemas#431

Merged
wwilsman merged 3 commits intomasterfrom
ww/load-core-schemas-first
Jul 20, 2021
Merged

🐛 Ensure core schemas are loaded before dependent snapshot schemas#431
wwilsman merged 3 commits intomasterfrom
ww/load-core-schemas-first

Conversation

@wwilsman
Copy link
Copy Markdown
Contributor

@wwilsman wwilsman commented Jul 20, 2021

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 addSchema util was updated to replace existing $id schemas 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 schemas array that can be passed to the addSchema call 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

@wwilsman wwilsman added the 🐛 bug Something isn't working label Jul 20, 2021
@wwilsman wwilsman requested a review from Robdel12 July 20, 2021 17:15
@wwilsman wwilsman enabled auto-merge (squash) July 20, 2021 17:20
Copy link
Copy Markdown
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

🏁

@wwilsman wwilsman merged commit fc806fc into master Jul 20, 2021
@wwilsman wwilsman deleted the ww/load-core-schemas-first branch July 20, 2021 17:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error Plugin: @percy/cli: can't resolve reference /snapshot#/properties/name from id /config/static

2 participants