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

Function describeCases

test/HotTestCases.template.js:42–390  ·  test/HotTestCases.template.js::describeCases
(config)

Source from the content-addressed store, hash-verified

40 * @param {SuiteConfig} config suite config
41 */
42const describeCases = (config) => {
43 class="cm">// universal targets run the same (ESM) bundle once per environment; the
44 class="cm">// suite forces module output, so probe with `output.module` set
45 const isUniversal = TestRunner.isUniversalTarget({
46 target: config.target,
47 output: { module: true }
48 });
49
50 describe(config.name, () => {
51 for (const category of categories) {
52 class="cm">// `universal` cases only run in the universal suite, and vice versa.
53 if ((category.name === class="st">"universal") !== isUniversal) {
54 continue;
55 }
56
57 describe(category.name, () => {
58 for (const testName of category.tests) {
59 const testDirectory = path.join(casesPath, category.name, testName);
60 const filterPath = path.join(testDirectory, class="st">"test.filter.js");
61 if (fs.existsSync(filterPath) && !require(filterPath)(config)) {
62 class="cm">// eslint-disable-next-line jest/no-disabled-tests
63 describe.skip(testName, () => {
64 it(class="st">"filtered", () => {});
65 });
66
67 continue;
68 }
69
70 describe(testName, () => {
71 /** @type {import(class="st">"../").Compiler} */
72 let compiler;
73
74 afterAll((/** @type {EXPECTED_ANY} */ callback) => {
75 compiler.close(callback);
76 compiler = /** @type {EXPECTED_ANY} */ (undefined);
77 });
78
79 it(`${testName} should compile`, (done) => {
80 const webpack = require(class="st">"..");
81
82 const outputDirectory = path.join(
83 __dirname,
84 class="st">"js",
85 `hot-cases-${config.name}`,
86 category.name,
87 testName
88 );
89 rimraf.sync(outputDirectory);
90 const recordsPath = path.join(outputDirectory, class="st">"records.json");
91 const fakeUpdateLoaderOptions = {
92 updateIndex: 0
93 };
94 const configPath = path.join(testDirectory, class="st">"webpack.config.js");
95 /** @type {import(class="st">"../").Configuration} */
96 let options = /** @type {import(class="st">"../").Configuration} */ ({});
97 if (fs.existsSync(configPath)) options = require(configPath);
98 if (
99 typeof (/** @type {EXPECTED_ANY} */ (options)) === class="st">"function"

Callers

nothing calls this directly

Calls 8

afterAllFunction · 0.85
requireFunction · 0.70
itFunction · 0.50
webpackFunction · 0.50
isUniversalTargetMethod · 0.45
closeMethod · 0.45
pushMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected