Next.js: Use jest-puppeteer for auto deploy with now

Created on 18 Nov 2019  路  3Comments  路  Source: vercel/next.js

Question about Next.js

My question is about using jest-puppeteer(or any other tools for integration tests) with next.js and auto deploy feature from now. When one creates a project with nextjs and wants to test it using circleci or any other ci for that matter for every PR, one can use jest-puppeteer for integration tests. Now creates a staging deploy for a PR and provides two links to access this deploy

  • https:zeit.co/<username>/<project-name>/<commit>
  • https:<branch-name>.<username>.now.sh

My question is whether there is a preferred method of how to access these links from one's CI. Sure one can generate the second one. And if there are any good practices about how to go about this? There is also a question about delaying the testing in the CI until now has deployed the PR.

I have not found any examples in your repo and googling around didn't really got me any results. Perhaps this issue can help others too. Thank you!

Most helpful comment

Hello @antonk52 ,

You have a few very important questions embedded in your text. I hope to answer all of them successfully with the following:

Q: How can I retrieve the URL of my deployment?
_A1:_ You can drop our bot and use GitHub actions to leverage the CLI: OUTPUT="$(now -t <token>)" && echo $OUTPUT. Do notice that this is a DIY solution since it will require a manual setup of workflows.
_A2:_ Doing a call to the API is also a good fit if you want to deal with more levels of customization. Check this here.
_A3:_ We are pushing updated to ZEIT Now so you can better manage staging environments. So it is quite possible we will give you a better experience in the future with "staging URLs".
_PS_ It is not possible to "extract" the URL generated by our BOT, unless you use the GitHub API or other tweaks on GitHub's side.

Q: How do I know if my deployment is READY?
_A: We simply do a pooling to our API in our CLI source code. You can see the endpoint here._

Q: Do you recommend any tools for tests?
_A1: At ZEIT, we use Checkly, which gives you a toolbelt at your disposal._
_A2: Check https://spectrum.chat/zeit/now/how-to-setup-ghost-inspector-with-now-github~d1789606-f719-44a9-9613-99d47485393c as well_

If you have any questions, let me know.

All 3 comments

Hello @antonk52 ,

You have a few very important questions embedded in your text. I hope to answer all of them successfully with the following:

Q: How can I retrieve the URL of my deployment?
_A1:_ You can drop our bot and use GitHub actions to leverage the CLI: OUTPUT="$(now -t <token>)" && echo $OUTPUT. Do notice that this is a DIY solution since it will require a manual setup of workflows.
_A2:_ Doing a call to the API is also a good fit if you want to deal with more levels of customization. Check this here.
_A3:_ We are pushing updated to ZEIT Now so you can better manage staging environments. So it is quite possible we will give you a better experience in the future with "staging URLs".
_PS_ It is not possible to "extract" the URL generated by our BOT, unless you use the GitHub API or other tweaks on GitHub's side.

Q: How do I know if my deployment is READY?
_A: We simply do a pooling to our API in our CLI source code. You can see the endpoint here._

Q: Do you recommend any tools for tests?
_A1: At ZEIT, we use Checkly, which gives you a toolbelt at your disposal._
_A2: Check https://spectrum.chat/zeit/now/how-to-setup-ghost-inspector-with-now-github~d1789606-f719-44a9-9613-99d47485393c as well_

If you have any questions, let me know.

Wow really did not expect such a detailed answer. Thanks a lot, this definitely answers my question

There's also a deploy event as ZEIT Now creates GitHub deployments automatically, so you can trigger GH actions based on that too (using the ZEIT Now GitHub integration).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lixiaoyan picture lixiaoyan  路  3Comments

irrigator picture irrigator  路  3Comments

pie6k picture pie6k  路  3Comments

knipferrc picture knipferrc  路  3Comments

formula349 picture formula349  路  3Comments