MCPcopy
hub / github.com/webpack/webpack / describeCases

Function describeCases

test/ConfigTestCases.template.js:81–643  ·  test/ConfigTestCases.template.js::describeCases
(config)

Source from the content-addressed store, hash-verified

79 * @param {SuiteConfig} config suite config
80 */
81const describeCases = (config) => {
82 describe(config.name, () => {
83 /** @type {ReturnType<typeof captureStdio>} */
84 let stderr;
85
86 beforeEach(() => {
87 stderr = captureStdio(process.stderr, true);
88 });
89
90 afterEach(() => {
91 stderr.restore();
92 });
93
94 jest.setTimeout(20000);
95
96 for (const category of categories) {
97 class="cm">// eslint-disable-next-line no-loop-func
98 describe(category.name, () => {
99 for (const testName of category.tests) {
100 class="cm">// eslint-disable-next-line no-loop-func
101 describe(testName, () => {
102 const testDirectory = path.join(casesPath, category.name, testName);
103 const filterPath = path.join(testDirectory, class="st">"test.filter.js");
104 if (fs.existsSync(filterPath) && !require(filterPath)(config)) {
105 class="cm">// eslint-disable-next-line jest/no-disabled-tests
106 describe.skip(testName, () => {
107 it(class="st">"filtered", () => {});
108 });
109
110 return;
111 }
112 /** @type {string[]} */
113 const infraStructureLog = [];
114 /** @type {string[]} */
115 const infraStructureErrors = [];
116 const outBaseDir = path.join(__dirname, class="st">"js");
117 const testSubPath = path.join(config.name, category.name, testName);
118 const outputDirectory = path.join(outBaseDir, testSubPath);
119 const cacheDirectory = path.join(outBaseDir, class="st">".cache", testSubPath);
120 /** @type {import(class="st">"../").Configuration} */
121 let options;
122 /** @type {import(class="st">"../").Configuration[]} */
123 let optionsArr;
124 /** @type {TestConfig} */
125 let testConfig;
126
127 registerPerCaseSnapshotHooks(testDirectory, config.name);
128
129 beforeAll(async () => {
130 options = /** @type {import(class="st">"../").Configuration} */ (
131 await prepareOptions(
132 require(path.join(testDirectory, class="st">"webpack.config.js")),
133 { testPath: outputDirectory }
134 )
135 );
136 optionsArr = [...(Array.isArray(options) ? options : [options])];
137 for (const [idx, options] of optionsArr.entries()) {
138 if (!options.context) options.context = testDirectory;

Callers

nothing calls this directly

Calls 15

beforeAllFunction · 0.85
prepareOptionsFunction · 0.85
setDefaultTimeoutFunction · 0.85
afterAllFunction · 0.85
handleFatalErrorFunction · 0.85
isArrayMethod · 0.80
entriesMethod · 0.80
requireFunction · 0.70
createLoggerFunction · 0.70
onCompiledFunction · 0.70
resolveMethod · 0.65

Tested by

no test coverage detected