Skip to content

chore(nextjs): Suppress warning message about hideSourceMaps option in tests #5708

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/nextjs/test/config/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ export const mkdtempSyncSpy = jest.spyOn(fs, 'mkdtempSync');
afterEach(() => {
mkdtempSyncSpy.mockClear();
});

// TODO (v8): This shouldn't be necessary once `hideSourceMaps` gets a default value, even for the updated error message
// eslint-disable-next-line @typescript-eslint/unbound-method
const realConsoleWarn = global.console.warn;
global.console.warn = (...args: unknown[]) => {
// Suppress the warning message about the `hideSourceMaps` option. This is better than forcing a value for
// `hideSourceMaps` because that would mean we couldn't test it easily and would muddy the waters of other tests. Note
// that doing this here, as a side effect, only works because the tests which trigger this warning are the same tests
// which need other mocks from this file.
if (typeof args[0] === 'string' && args[0].includes('your original code may be visible in browser devtools')) {
return;
}

return realConsoleWarn(...args);
};
3 changes: 3 additions & 0 deletions packages/nextjs/test/integration/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const moduleExports = {
},
sentry: {
experiments: { autoWrapDataFetchers: true },
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
// TODO (v8): This can come out in v8, because this option will get a default value
hideSourceMaps: false,
},
};
const SentryWebpackPluginOptions = {
Expand Down
3 changes: 3 additions & 0 deletions packages/nextjs/test/integration/next10.config.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const moduleExports = {
},
sentry: {
experiments: { autoWrapDataFetchers: true },
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
// TODO (v8): This can come out in v8, because this option will get a default value
hideSourceMaps: false,
},
};

Expand Down
3 changes: 3 additions & 0 deletions packages/nextjs/test/integration/next11.config.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const moduleExports = {
},
sentry: {
experiments: { autoWrapDataFetchers: true },
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
// TODO (v8): This can come out in v8, because this option will get a default value
hideSourceMaps: false,
},
};

Expand Down