Skip to content

Commit 7d8eb6f

Browse files
committed
test: adds unit test for doNotLoadConfig in webpack
1 parent f797cfb commit 7d8eb6f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app-config-webpack/src/index.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,28 @@ describe('frontend-webpack-project example', () => {
284284
});
285285
});
286286
});
287+
288+
it('builds the project with doNotLoadConfig', async () => {
289+
process.env.APP_CONFIG = 'null';
290+
process.env.APP_CONFIG_ENV = 'test';
291+
292+
await new Promise<void>((done, reject) => {
293+
webpack([createOptions({ doNotLoadConfig: true })], (err, stats) => {
294+
if (err) return reject(err);
295+
if (!stats) return reject(new Error('no stats'));
296+
if (stats.hasErrors()) reject(stats.toString());
297+
298+
const { children } = stats.toJson({ source: true });
299+
const [{ modules = [] }] = children || [];
300+
301+
expect(
302+
modules.some(({ source }) => source?.includes('Config is not loaded in _appConfig')),
303+
).toBe(true);
304+
305+
done();
306+
});
307+
});
308+
});
287309
});
288310

289311
describe('regex', () => {

0 commit comments

Comments
 (0)