MCPcopy Create free account
hub / github.com/webpack/less-loader / createTestCase

Function createTestCase

test/validate-options.test.js:67–91  ·  view source on GitHub ↗

* @param {string} key key * @param {EXPECTED_ANY} value value * @param {string} type type * @returns {Promise } created test case

(key, value, type)

Source from the content-addressed store, hash-verified

65 * @returns {Promise<void>} created test case
66 */
67 function createTestCase(key, value, type) {
68 it(`should ${
69 type === "success" ? "successfully validate" : "throw an error on"
70 } the "${key}" option with "${stringifyValue(value)}" value`, async (t) => {
71 const compiler = getCompiler("./basic.less", {
72 [key]: value,
73 });
74 let stats;
75
76 try {
77 stats = await compile(compiler);
78 } finally {
79 if (type === "success") {
80 assert.strictEqual(stats.hasErrors(), false);
81 } else if (type === "failure") {
82 const {
83 compilation: { errors },
84 } = stats;
85
86 assert.strictEqual(errors.length, 1);
87 t.assert.snapshot(errors[0].error.message);
88 }
89 }
90 });
91 }
92
93 for (const [key, values] of Object.entries(tests)) {
94 for (const type of Object.keys(values)) {

Callers 1

Calls 1

stringifyValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…