function captureWarnings(innerFunc) {
  const msgs = [];
  const nativeConsoleWarn = console.warn;
  try {
    console.warn = function (msg) {
      msgs.push(msg);
    };
    innerFunc();
  } finally {
    console.warn = nativeConsoleWarn;
  }
  return msgs;
}
Captures the strings sent to console.warn() when calling a function.
Copies from core.
@param {Function} innerFunc The function where warnings may called.
@returns {Array<string>} The warning messages (only the first arguments).