From 6cd3afbcf1666ee683dae9872a3df00bf1e2f096 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 11 Sep 2024 13:14:42 +0800 Subject: [PATCH] test --- .../__snapshots__/environments.test.ts.snap | 2 +- packages/core/tests/environments.test.ts | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/core/tests/__snapshots__/environments.test.ts.snap b/packages/core/tests/__snapshots__/environments.test.ts.snap index 164fdd2a1c..bbc4147add 100644 --- a/packages/core/tests/__snapshots__/environments.test.ts.snap +++ b/packages/core/tests/__snapshots__/environments.test.ts.snap @@ -1383,7 +1383,7 @@ exports[`environment config > should support modify single environment config by } `; -exports[`environment config > tools.rspack / bundlerChain can be used in environment config 1`] = ` +exports[`environment config > tools.rspack / bundlerChain can be configured in environment config 1`] = ` [ { "context": "", diff --git a/packages/core/tests/environments.test.ts b/packages/core/tests/environments.test.ts index 7107bafc32..fc5995897c 100644 --- a/packages/core/tests/environments.test.ts +++ b/packages/core/tests/environments.test.ts @@ -1,4 +1,5 @@ import { join } from 'node:path'; +import { matchPlugin } from '@scripts/test-helper'; import { type RsbuildPlugin, createRsbuild } from '../src'; describe('environment config', () => { @@ -327,7 +328,7 @@ describe('environment config', () => { expect(environmentConfigs).toMatchSnapshot(); }); - it('tools.rspack / bundlerChain can be used in environment config', async () => { + it('tools.rspack / bundlerChain can be configured in environment config', async () => { const rsbuild = await createRsbuild({ rsbuildConfig: { tools: { @@ -366,4 +367,28 @@ describe('environment config', () => { const configs = await rsbuild.initConfigs(); expect(configs).toMatchSnapshot(); }); + + it('dev.hmr can be configured in environment config', async () => { + const rsbuild = await createRsbuild({ + rsbuildConfig: { + environments: { + web: { + dev: { + hmr: false, + }, + }, + web2: { + dev: { + hmr: true, + }, + }, + }, + }, + }); + + const configs = await rsbuild.initConfigs(); + + expect(matchPlugin(configs[0], 'HotModuleReplacementPlugin')).toBeFalsy(); + expect(matchPlugin(configs[1], 'HotModuleReplacementPlugin')).toBeTruthy(); + }); });