Skip to content

Commit

Permalink
tests: add tests for env in configGroup (#2012)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Nov 2, 2020
1 parent 270efc6 commit e995923
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@ describe('ConfigGroup', function () {
expect(result.options).toEqual(expectedOptions);
expect(result.outputOptions).toEqual({});
});

it('should handle different env formats', async () => {
const result = await ConfigGroup({
env: { test: true, name: 'Hisoka' },
config: [resolve(__dirname, './env.webpack.config.cjs')],
});
const expectedOptions = { mode: 'staging', name: 'Hisoka' };
expect(result.options).toEqual(expectedOptions);
expect(result.outputOptions).toEqual({});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (env) {
const configName = env.name;
return {
name: configName,
mode: env.test ? 'staging' : 'production',
};
};

0 comments on commit e995923

Please sign in to comment.