Skip to content

Commit 4eb0a5d

Browse files
committed
mock loadModule for some tests
1 parent 50a1ce2 commit 4eb0a5d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/nextjs/test/config/webpack/constructWebpackConfig.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it, vi } from 'vitest';
1+
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
22

33
// mock helper functions not tested directly in this file
44
import '../mocks';
@@ -14,9 +14,16 @@ import {
1414
userNextConfig,
1515
} from '../fixtures';
1616
import { materializeFinalNextConfig, materializeFinalWebpackConfig } from '../testUtils';
17+
import * as core from '@sentry/core';
1718

1819
describe('constructWebpackConfigFunction()', () => {
1920
it('includes expected properties', async () => {
21+
vi.spyOn(core, 'loadModule').mockImplementation(() => ({
22+
sentryWebpackPlugin: () => ({
23+
_name: 'sentry-webpack-plugin',
24+
}),
25+
}));
26+
2027
const finalWebpackConfig = await materializeFinalWebpackConfig({
2128
exportedNextConfig,
2229
incomingWebpackConfig: serverWebpackConfig,
@@ -49,6 +56,11 @@ describe('constructWebpackConfigFunction()', () => {
4956

5057
it('automatically enables deleteSourcemapsAfterUpload for client builds when not explicitly set', async () => {
5158
const getWebpackPluginOptionsSpy = vi.spyOn(getWebpackPluginOptionsModule, 'getWebpackPluginOptions');
59+
vi.spyOn(core, 'loadModule').mockImplementation(() => ({
60+
sentryWebpackPlugin: () => ({
61+
_name: 'sentry-webpack-plugin',
62+
}),
63+
}));
5264

5365
await materializeFinalWebpackConfig({
5466
exportedNextConfig,
@@ -114,6 +126,12 @@ describe('constructWebpackConfigFunction()', () => {
114126
});
115127

116128
it('uses `hidden-source-map` as `devtool` value for client-side builds', async () => {
129+
vi.spyOn(core, 'loadModule').mockImplementation(() => ({
130+
sentryWebpackPlugin: () => ({
131+
_name: 'sentry-webpack-plugin',
132+
}),
133+
}));
134+
117135
const finalClientWebpackConfig = await materializeFinalWebpackConfig({
118136
exportedNextConfig: exportedNextConfig,
119137
incomingWebpackConfig: clientWebpackConfig,

0 commit comments

Comments
 (0)