MCPcopy
hub / github.com/webpack/webpack / monotonicTest

Function monotonicTest

test/ProgressPlugin.test.js:191–212  ·  test/ProgressPlugin.test.js::monotonicTest
(/** @type {(...args: EXPECTED_ANY[]) => EXPECTED_ANY} */ createCompiler)

Source from the content-addressed store, hash-verified

189
190 const monotonicTest =
191 (/** @type {(...args: EXPECTED_ANY[]) => EXPECTED_ANY} */ createCompiler) =>
192 () => {
193 /** @type {{ value: number, text: string }[]} */
194 const handlerCalls = [];
195 const compiler = createCompiler({
196 handler: (/** @type {number} */ p, /** @type {string[]} */ ...args) => {
197 handlerCalls.push({ value: p, text: `${p}% ${args.join(class="st">" ")}` });
198 }
199 });
200
201 return runCompilerAsync(compiler).then(() => {
202 let lastLine = handlerCalls[0];
203 for (const line of handlerCalls) {
204 if (line.value < lastLine.value) {
205 throw new Error(
206 `Progress value is not monotonic increasing:\n${lastLine.text}\n${line.text}`
207 );
208 }
209 lastLine = line;
210 }
211 });
212 };
213
214 it(
215 class="st">"should have monotonic increasing progress",

Callers 1

Calls 3

runCompilerAsyncFunction · 0.85
createCompilerFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected