Skip to content

Commit 249e64d

Browse files
authored
chore(nextjs): Suppress warning message about hideSourceMaps option in tests (#5708)
The warning added in #5649 isn't relevant to our overall nextjs test suite. This therefore suppresses it in both unit and integration tests.
1 parent 781485e commit 249e64d

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

packages/nextjs/test/config/mocks.ts

+15
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,18 @@ export const mkdtempSyncSpy = jest.spyOn(fs, 'mkdtempSync');
5454
afterEach(() => {
5555
mkdtempSyncSpy.mockClear();
5656
});
57+
58+
// TODO (v8): This shouldn't be necessary once `hideSourceMaps` gets a default value, even for the updated error message
59+
// eslint-disable-next-line @typescript-eslint/unbound-method
60+
const realConsoleWarn = global.console.warn;
61+
global.console.warn = (...args: unknown[]) => {
62+
// Suppress the warning message about the `hideSourceMaps` option. This is better than forcing a value for
63+
// `hideSourceMaps` because that would mean we couldn't test it easily and would muddy the waters of other tests. Note
64+
// that doing this here, as a side effect, only works because the tests which trigger this warning are the same tests
65+
// which need other mocks from this file.
66+
if (typeof args[0] === 'string' && args[0].includes('your original code may be visible in browser devtools')) {
67+
return;
68+
}
69+
70+
return realConsoleWarn(...args);
71+
};

packages/nextjs/test/integration/next.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const moduleExports = {
66
},
77
sentry: {
88
experiments: { autoWrapDataFetchers: true },
9+
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
10+
// TODO (v8): This can come out in v8, because this option will get a default value
11+
hideSourceMaps: false,
912
},
1013
};
1114
const SentryWebpackPluginOptions = {

packages/nextjs/test/integration/next10.config.template

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const moduleExports = {
77
},
88
sentry: {
99
experiments: { autoWrapDataFetchers: true },
10+
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
11+
// TODO (v8): This can come out in v8, because this option will get a default value
12+
hideSourceMaps: false,
1013
},
1114
};
1215

packages/nextjs/test/integration/next11.config.template

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const moduleExports = {
88
},
99
sentry: {
1010
experiments: { autoWrapDataFetchers: true },
11+
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
12+
// TODO (v8): This can come out in v8, because this option will get a default value
13+
hideSourceMaps: false,
1114
},
1215
};
1316

0 commit comments

Comments
 (0)