forked from webpack/webpack-cli
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
experiments-flag.test.js
26 lines (21 loc) · 1.01 KB
/
experiments-flag.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
const { run, hyphenToUpperCase } = require('../utils/test-utils');
const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags');
const experimentsFlags = flagsFromCore.filter(({ name }) => name.startsWith('experiments-'));
describe('experiments option related flag', () => {
experimentsFlags.forEach((flag) => {
// extract property name from flag name
const property = flag.name.split('experiments-')[1];
const propName = hyphenToUpperCase(property);
it(`should config ${flag.name} correctly`, () => {
const { stderr, stdout } = run(__dirname, [`--${flag.name}`]);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`${propName}: true`);
});
it(`should config --no-${flag.name} correctly`, () => {
const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`${propName}: false`);
});
});
});