-
Notifications
You must be signed in to change notification settings - Fork 88
chore: add e2e #789
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
chore: add e2e #789
Conversation
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.
Woohoo!
package.json
Outdated
@@ -10,8 +10,9 @@ | |||
"scripts": { | |||
"build:demo": "next build demo", | |||
"cy:open": "cypress open --config-file cypress/config/all.json", | |||
"cy:run": "cypress run --config-file cypress/config/all.json", | |||
"cy:run": "cypress run --config-file ../cypress/config/ci.json", |
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.
Having this expect to be run from in the demo directory is quite confusing. Is this required?
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.
It is required in order to have the paths point to the correct config files in the ci, since ci uses the demo folder as the root, but I can change the command to be named ci:cypress
instead so no one tries to run it locally.
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.
Aaah, ok. This being because demo doesn;t have a package.json of its own
// Set a random page between 1 and 100 | ||
const randomPage = Math.floor(Math.random() * 100) + 1 | ||
// FIXME: stub out in dev | ||
const server = dev ? `https://api.tvmaze.com/shows?page=${randomPage}` : `https://api.tvmaze.com/shows?page=${randomPage}`; |
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.
You could find the base server so you can load the stub by checking if document
is available, and either getting it from there or otherwise seeing if you can get it from context.req
async redirects() { | ||
return [ | ||
{ | ||
source: '/redirectme', |
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.
Not one for this PR, but adding a regex-based rewrite would be good
} | ||
) | ||
cy.visit('/previewTest') | ||
cy.findByText('Number: 3') |
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.
My preview mode PR changes the text here, so this will need an update
|
||
it('should show image using next/image', () => { | ||
cy.visit('/image') | ||
cy.findByRole('img', { name: /shiba inu dog looks through a window/i }) |
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.
Will this check if the image actually loads?
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.
Good call, I'll add the same width/height as the other image test
Co-authored-by: Matt Kane <matt.kane@netlify.com>
Summary
Add tests for the plugin. Tests for other demo sites (basepath, nx, and more) will follow
public
Test plan
Visit deploy logs to see it being run with the plugin otherwise:
npm i
npm run cy:open
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal (small picture)
https://github.com/netlify/pod-ecosystem-integrations/issues/33
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was published correctly.