Skip to content

ref(test): Break up nextjs config tests #5541

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

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Aug 8, 2022

In anticipation of adding more tests for the code in src/config in the nextjs SDK, this breaks up the (very long) single file which had been covering the entire directory into multiple files, extracting some mocks, fixtures, and utils along they way into helper modules.

The entire test suite could probably stand to be revisited/cleaned up, but for now this just distributes things into different files.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice, looks like a good change to me!
I have one question but if this works as I think it does, then I'm happy to ✅

(Admittedly, I didn't look at specific tests since you said you just splitted them up )

exportedNextConfig: ExportedNextConfig,
userSentryWebpackPluginConfig?: Partial<SentryWebpackPluginOptions>,
): NextConfigObject {
const sentrifiedConfig = withSentryConfig(exportedNextConfig, userSentryWebpackPluginConfig);
Copy link
Member

Choose a reason for hiding this comment

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

Lol "sentrified"
(We should make this a thing!)

Comment on lines +45 to +47
afterAll(() => {
rimraf.sync(TEMP_DIR_PATH);
});
Copy link
Member

@Lms24 Lms24 Aug 9, 2022

Choose a reason for hiding this comment

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

Wait, if I register a (before|after)(Each|All) call outside a describe closure, does that mean it runs for all tests in this directory?
If yes, that's totally fine, I just haven't seen this before, which is why I'm asking

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it only runs for the tests which import the file containing it. Neat, huh?

Honestly, before yesterday I didn't know that, either. I knew you could have a (before|after)(Each|All) call outside a describe in the same file (so, module level), but not that it could be in a totally separate file. But I took a flier and it ended up working out! (I tested it by logging inside the afterAll() function, and it only logged three times, once from inside of each file importing mocks.ts.)

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, but makes sense! Thanks for explaining!

@lobsterkatie lobsterkatie merged commit 9b7f432 into master Aug 10, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-break-up-config-tests branch August 10, 2022 22:19
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