* @param {string} key key * @param {EXPECTED_ANY} value value * @param {string} type type * @returns {Promise } created test case
(key, value, type)
| 78 | * @returns {Promise<void>} created test case |
| 79 | */ |
| 80 | async function createTestCase(key, value, type) { |
| 81 | it(`should ${ |
| 82 | type === "success" ? "successfully validate" : "throw an error on" |
| 83 | } the "${key}" option with "${stringifyValue(value)}" value`, async (t) => { |
| 84 | const testId = getTestId("language", "scss"); |
| 85 | const compiler = getCompiler(testId, { |
| 86 | loader: { |
| 87 | options: { |
| 88 | implementation: await getImplementationByName("dart-sass"), |
| 89 | [key]: value, |
| 90 | }, |
| 91 | }, |
| 92 | }); |
| 93 | let stats; |
| 94 | |
| 95 | try { |
| 96 | stats = await compile(compiler); |
| 97 | } finally { |
| 98 | if (type === "success") { |
| 99 | assert.strictEqual(stats.hasErrors(), false); |
| 100 | } else if (type === "failure") { |
| 101 | const { |
| 102 | compilation: { errors }, |
| 103 | } = stats; |
| 104 | |
| 105 | assert.strictEqual(errors.length, 1); |
| 106 | t.assert.snapshot( |
| 107 | ((fn) => { |
| 108 | try { |
| 109 | fn(); |
| 110 | return null; |
| 111 | } catch (err) { |
| 112 | return err.message; |
| 113 | } |
| 114 | })(() => { |
| 115 | throw new Error(errors[0].error.message); |
| 116 | }), |
| 117 | ); |
| 118 | } |
| 119 | } |
| 120 | }); |
| 121 | } |
| 122 | |
| 123 | for (const [key, values] of Object.entries(tests)) { |
| 124 | for (const type of Object.keys(values)) { |
no test coverage detected
searching dependent graphs…