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

[integration] [cypress-gatsby] feat: Add Gatsby API support to our Cypress plugin #8641

Merged
merged 13 commits into from
Oct 2, 2018
Merged

[integration] [cypress-gatsby] feat: Add Gatsby API support to our Cypress plugin #8641

merged 13 commits into from
Oct 2, 2018

Conversation

vtenfys
Copy link
Contributor

@vtenfys vtenfys commented Sep 29, 2018

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 with gatsby serve since the handlers aren't setup in time for the API calls, but it works with gatsby develop working in the last two commits

@vtenfys vtenfys requested a review from a team as a code owner September 29, 2018 17:28
@vtenfys vtenfys changed the title [integration] feat: Add Gatsby API support to Cypress [integration] [cypress-gatsby] feat: Add Gatsby API support to our Cypress plugin Sep 29, 2018
David Bailey and others added 6 commits September 29, 2018 18:33
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
Copy link
Contributor

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

@pieh
Copy link
Contributor

pieh commented Sep 30, 2018

LGTM, only tiny thing we could do is to re-add cy.waitForRouteChange cypress command that would just call new cy.waitForAPI(`onRouteUpdate`) for backward compat if someone actually used that outside of our repo (or just bump version to 0.2.0)

@@ -1 +1 @@
// no-op
import "./commands"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice change!

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

LGTM

@vtenfys
Copy link
Contributor Author

vtenfys commented Oct 2, 2018

@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(
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @pieh! 👍

@pieh
Copy link
Contributor

pieh commented Oct 2, 2018

@davidbailey00 is there anything you still want to do in this PR or it's ready to merge?

@vtenfys
Copy link
Contributor Author

vtenfys commented Oct 2, 2018

@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 :)

@DSchau
Copy link
Contributor

DSchau commented Oct 2, 2018

@davidbailey00 @pieh merging :)

@DSchau DSchau merged commit 0fc973c into gatsbyjs:master Oct 2, 2018
@DSchau
Copy link
Contributor

DSchau commented Oct 2, 2018

Successfully published:
 - [email protected]

lipis added a commit to lipis/gatsby that referenced this pull request Oct 3, 2018
* '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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants