11import { createStubRsbuild } from '@scripts/test-helper' ;
2+ import { createRsbuild } from '../src' ;
23import { pluginOutput } from '../src/plugins/output' ;
34
45describe ( 'plugin-output' , ( ) => {
@@ -179,8 +180,8 @@ describe('plugin-output', () => {
179180 } ) ;
180181
181182 it ( 'should replace `<port>` placeholder with server.port' , async ( ) => {
182- const rsbuild = await createStubRsbuild ( {
183- plugins : [ pluginOutput ( ) ] ,
183+ vi . stubEnv ( 'NODE_ENV' , 'development' ) ;
184+ const rsbuild = await createRsbuild ( {
184185 rsbuildConfig : {
185186 server : { port : 4000 } ,
186187 dev : {
@@ -190,12 +191,12 @@ describe('plugin-output', () => {
190191 } ) ;
191192 const [ config ] = await rsbuild . initConfigs ( ) ;
192193 expect ( config ?. output ?. publicPath ) . toEqual ( 'http://example-4000.com:4000/' ) ;
194+ vi . unstubAllEnvs ( ) ;
193195 } ) ;
194196
195197 it ( 'should replace `<port>` placeholder of `output.assetPrefix` with default port' , async ( ) => {
196198 vi . stubEnv ( 'NODE_ENV' , 'production' ) ;
197- const rsbuild = await createStubRsbuild ( {
198- plugins : [ pluginOutput ( ) ] ,
199+ const rsbuild = await createRsbuild ( {
199200 rsbuildConfig : {
200201 output : {
201202 assetPrefix : 'http://example.com:<port>/' ,
@@ -205,5 +206,6 @@ describe('plugin-output', () => {
205206
206207 const [ config ] = await rsbuild . initConfigs ( ) ;
207208 expect ( config ?. output ?. publicPath ) . toEqual ( 'http://example.com:3000/' ) ;
209+ vi . unstubAllEnvs ( ) ;
208210 } ) ;
209211} ) ;
0 commit comments