Skip to content

Conversation

onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Oct 9, 2024

Adds e2e tests using a plain project from create-next-app.

@onurtemizkan onurtemizkan force-pushed the onur/nextjs-e2e-tests branch from 91c0157 to 03c3bde Compare October 9, 2024 10:52
Comment on lines +1 to +11
### 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Lms24, @lforst -- Could we create a test project and set these env variables on the CI?

Copy link

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?

Copy link
Collaborator Author

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 and start. Only test if the project runs on dev mode which is working without the need for these.

Copy link

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.

Copy link
Collaborator Author

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.

@onurtemizkan onurtemizkan marked this pull request as ready for review October 16, 2024 14:39
Copy link

@lforst lforst left a 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 {
Copy link

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.

Comment on lines 33 to 44
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,
},
);
Copy link

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated 👍 4a6c56a

@onurtemizkan onurtemizkan force-pushed the onur/nextjs-e2e-tests branch from 30d557f to d20aa10 Compare October 17, 2024 12:54
Copy link

@lforst lforst left a comment

Choose a reason for hiding this comment

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

nice, thank you

@lforst lforst changed the title test: Add NextJS E2E Tests test: Add Next.js E2E tests Oct 23, 2024
@lforst lforst merged commit 5d3257e into master Oct 23, 2024
15 checks passed
@lforst lforst deleted the onur/nextjs-e2e-tests branch October 23, 2024 07:48
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.

2 participants