-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[integration] [cypress-gatsby] feat: Add Gatsby API support to our Cypress plugin #8641
Conversation
* This fixes problems with APIs running earlier than waitForAPI * Also replace all instances of waitForRouteChange with waitForAPI
Detect Cypress via window.Cypress, and store resolved APIs to a global variable, so that it works correctly even if the handler isn't setup when the API is called.
@@ -0,0 +1,32 @@ | |||
let resolve = null | |||
let promise = null |
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 doesn't have to be global - it's used just in waitForAPI
LGTM, only tiny thing we could do is to re-add |
@@ -1 +1 @@ | |||
// no-op | |||
import "./commands" |
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.
Nice change!
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.
LGTM
@pieh there's still the issue with the unnecessary global variable - I'm at Memiah this week so can you fix this please? |
@@ -19,3 +19,11 @@ Cypress.Commands.add( | |||
}) | |||
} | |||
) | |||
|
|||
Cypress.Commands.add( |
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.
👍
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.
Thanks @pieh! 👍
@davidbailey00 is there anything you still want to do in this PR or it's ready to merge? |
@pieh I think it's ready now! Personally I'm not sure if it's necessary to alias the old command since we never published this package, but there's no harm in doing so just to be safe :) |
@davidbailey00 @pieh merging :) |
|
* 'master' of github.com:gatsbyjs/gatsby: (72 commits) fix: fix wording in plopfile (gatsbyjs#8735) fix: navigateTo deprecation message (gatsbyjs#8745) Add deploying-to-heroku.md (gatsbyjs#8721) fix(docs): Link to instructions on adding to plugin library (gatsbyjs#8686) updated gatsby-plugin-remove-trailing-slashes docs to include link re… (gatsbyjs#8720) feat(www/starters): Add TypeScript and Contentful starter (gatsbyjs#8704) fix(docs): fix typos in template doc (gatsbyjs#8692) feat(www): change chevron direction on sticky responsive sidebar (gatsbyjs#8664) chore(release): Publish [integration] [cypress-gatsby] feat: Add Gatsby API support to our Cypress plugin (gatsbyjs#8641) chore(release): Publish fix(gatsby): add mjs config to webpack and resolve correctly (gatsbyjs#8717) feat(gatsby-plugin-netlify): add force option to createRedirect (gatsbyjs#8521) [www/starters] tweaks to fix DX for no GH token on www (gatsbyjs#8718) chore(release): Publish fix(gatsby-dev-cli): infer correct prefix from package path (gatsbyjs#8683) fix(www/starters): fix broken link to submission instructions (gatsbyjs#8715) chore(release): Publish feat(gatsby) : add createContentDigest helper (gatsbyjs#8687) feat: publish SendGrid case study blogpost (gatsbyjs#8592) ...
I've removed the
waitForRouteChange
API and replaced it with a universal handler for all the Gatsby APIs - this will allow us to use any other APIs easily from Cypress, without having to implement custom handlers for each one.Currently this isn't working withworking in the last two commitsgatsby serve
since the handlers aren't setup in time for the API calls, but it works withgatsby develop