/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/helpers/expectWarningFactory.js
31 строка
594 B
Alexander Akait
refactor: strict types for the test suite (#21147)
09 июн 2026, 20:15
Не верифицирован
09 июн 2026, 20:15
9bd0b91
Код
Авторство
О чём код?
"use strict"; module.exports = () => { /** @type {string[]} */ const warnings = []; /** @type {typeof console.warn} */ let oldWarn; beforeEach((done) => { oldWarn = console.warn; console.warn = (m) => warnings.push(m); done(); }); afterEach((done) => { expectWarning(); console.warn = oldWarn; done(); }); /** * @param {...(string | RegExp)} regexp expected warning patterns * @returns {void} */ const expectWarning = (...regexp) => { expect(warnings).toEqual(regexp.map((r) => expect.stringMatching(r))); warnings.length = 0; }; return expectWarning; };