-
-
Notifications
You must be signed in to change notification settings - Fork 76
test: Add Next.js E2E tests #684
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
Conversation
91c0157
to
03c3bde
Compare
### SENTRY TEST AUTH TOKEN ### | ||
SENTRY_TEST_AUTH_TOKEN="TEST_AUTH_TOKEN" | ||
|
||
### SENTRY TEST DSN ### | ||
SENTRY_TEST_DSN="TEST_DSN" | ||
|
||
### SENTRY TEST ORG ### | ||
SENTRY_TEST_ORG="TEST_ORG" | ||
|
||
### SENTRY TEST PROJECT ### | ||
SENTRY_TEST_PROJECT="TEST_PROJECT" No newline at end of file |
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.
Anecdotally we should avoid depending on any production systems for our tests. We recently stopped doing so in the main js repo because it was blocking us from cutting releases and merging a tad to often. Do you think it would be a hard requirement?
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 seems required for testing if the test project builds and runs in the production mode. When there's no valid AUTH_TOKEN
, the build fails as the webpack plugin is already set on the next.config
file. So, given there's no option to skip configuring next.config
in the wizard at the moment, we can instead do either:
- Try reverting the local changes on
next.config
file before building the test project. - Don't test the
build
andstart
. Only test if the project runs ondev
mode which is working without the need for these.
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.
Right, I think we would want to test build and start so I am on board with pointing to a prod project. We should just make sure that it is not blocking 1) Releases of the wizard 2) PRs 3) Local test runs.
We can point the tests to the sentry-javascript-sdks
org and the sentry-wizard-e2e-tests
project. I think this can simply be via the github action yaml. Do we need any secrets? If so I can ask for them to be added.
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.
Cool, so adding the AUTH_TOKEN
would be enough for now, I'll set the rest on the GA yaml.
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.
Love it. 2 small comments then I would ship it. Thanks a lot!
@@ -0,0 +1,42 @@ | |||
:root { |
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.
I would probably just remove the CSS files. They shouldn't add anything to the tests.
e2e-tests/tests/nextjs.test.ts
Outdated
if (packageManagerPrompted) { | ||
// Selecting `yarn` as the package manager | ||
wizardInstance.sendStdin(KEYS.DOWN); | ||
wizardInstance.sendStdin(KEYS.ENTER); | ||
} | ||
|
||
const routeThroughNextJsPrompted = await wizardInstance.waitForOutput( | ||
'Do you want to route Sentry requests in the browser through your Next.js server', | ||
{ | ||
timeout: 240_000, | ||
}, | ||
); |
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.
Is this order of operations prone to race conditions? Isn't it possible that the wizard emits "Do you want to ..." before we were able to attach the .waitForOutput() call.
I know it's a pain in the butt and makes the tests super unreadable, but we should probably err on the side of caution and attach the .waitForOutput before we send the ENTER
key, and then afterwards await it. Does that make sense? We have the same pattern in the JS repo E2E tests quite often.
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.
Updated 👍 4a6c56a
30d557f
to
d20aa10
Compare
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, thank you
Adds e2e tests using a plain project from
create-next-app
.