Skip to content

Commit 3357356

Browse files
committed
fix tests
1 parent ef23085 commit 3357356

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

packages/nextjs/test/config.test.ts

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const userNextConfig = {
2727
}),
2828
}),
2929
};
30-
const userSentryWebpackPluginConfig = { org: 'squirrelChasers', project: 'simulator', include: './thirdPartyMaps' };
30+
const userSentryWebpackPluginConfig = { org: 'squirrelChasers', project: 'simulator' };
31+
process.env.SENTRY_AUTH_TOKEN = 'dogsarebadatkeepingsecrets';
3132

3233
/** Mocks of the arguments passed to the result of `withSentryConfig` (when it's a function). */
3334
const runtimePhase = 'ball-fetching';
@@ -115,7 +116,7 @@ function materializeFinalNextConfig(
115116
*/
116117
async function materializeFinalWebpackConfig(options: {
117118
userNextConfig: ExportedNextConfig;
118-
userSentryWebpackPluginConfig?: SentryWebpackPluginOptions;
119+
userSentryWebpackPluginConfig?: Partial<SentryWebpackPluginOptions>;
119120
incomingWebpackConfig: WebpackConfigObject;
120121
incomingWebpackBuildContext: BuildContext;
121122
}): Promise<WebpackConfigObject> {
@@ -292,12 +293,45 @@ describe('webpack config', () => {
292293
});
293294

294295
describe('Sentry webpack plugin config', () => {
295-
it('includes expected properties', () => {
296-
// TODO
296+
it('includes expected properties', async () => {
297+
// also, can pull from either env or user config (see notes on specific properties below)
298+
const finalWebpackConfig = await materializeFinalWebpackConfig({
299+
userNextConfig,
300+
userSentryWebpackPluginConfig,
301+
incomingWebpackConfig: serverWebpackConfig,
302+
incomingWebpackBuildContext: serverBuildContext,
303+
});
304+
305+
expect(finalWebpackConfig.plugins?.[0].options).toEqual(
306+
expect.objectContaining({
307+
include: [
308+
// because this is the server build
309+
{ path: '.next/server/chunks/', urlPrefix: '~/_next/server/chunks' },
310+
{ path: '.next/server/pages/', urlPrefix: '~/_next/server/pages' },
311+
{ path: '.next/serverless/', urlPrefix: '~/_next/serverless' },
312+
],
313+
ignore: [], // default
314+
org: 'squirrelChasers', // from user webpack plugin config
315+
project: 'simulator', // from user webpack plugin config
316+
authToken: 'dogsarebadatkeepingsecrets', // picked up from env
317+
stripPrefix: ['webpack://_N_E/'], // default
318+
urlPrefix: `~/_next`, // default
319+
entries: expect.any(Function), // default, tested separately elsewhere
320+
release: 'doGsaREgReaT', // from build context
321+
dryRun: false, // based on buildContext.dev being false
322+
}),
323+
);
297324
});
298325

299-
it('preserves unrelated plugin config options', () => {
300-
// TODO
326+
it('preserves unrelated plugin config options', async () => {
327+
const finalWebpackConfig = await materializeFinalWebpackConfig({
328+
userNextConfig,
329+
userSentryWebpackPluginConfig: { ...userSentryWebpackPluginConfig, debug: true },
330+
incomingWebpackConfig: serverWebpackConfig,
331+
incomingWebpackBuildContext: serverBuildContext,
332+
});
333+
334+
expect((finalWebpackConfig.plugins?.[0].options as SentryWebpackPluginOptions).debug).toEqual(true);
301335
});
302336

303337
it('warns when overriding certain default values', () => {

0 commit comments

Comments
 (0)