runWatch = (cwd, args = [], options = {}) => {
    return new Promise((resolve, reject) => {
      const process = createProcess(cwd, args, options);
      const outputKillStr = options.killString || /webpack \d+\.\d+\.\d/;
      const stdoutKillStr = options.stdoutKillStr;
      const stderrKillStr = options.stderrKillStr;

      let isStdoutDone = false;
      let isStderrDone = false;

      process.stdout.pipe(
        new Writable({
          write(chunk, encoding, callback) {
            const output = stripAnsi(chunk.toString("utf8"));

            if (stdoutKillStr && stdoutKillStr.test(output)) {
              isStdoutDone = true;
            } else if (!stdoutKillStr && outputKillStr.test(output)) {
              processKill(process);
            }

            if (isStdoutDone && isStderrDone) {
              processKill(process);
            }

            callback();
          },
        }),
      );

      process.stderr.pipe(
        new Writable({
          write(chunk, encoding, callback) {
            const output = stripAnsi(chunk.toString("utf8"));

            if (stderrKillStr && stderrKillStr.test(output)) {
              isStderrDone = true;
            } else if (!stderrKillStr && outputKillStr.test(output)) {
              processKill(process);
            }

            if (isStdoutDone && isStderrDone) {
              processKill(process);
            }

            callback();
          },
        }),
      );

      process
        .then((result) => {
          resolve(result);
        })
        .catch((error) => {
          reject(error);
        });
    });
  }
Run the webpack CLI in watch mode for a test case.

@param {string} cwd The path to folder that contains test
@param {Array<string>} args Array of arguments
@param {Object<string, any>} options Options for tests
@returns {Object} The webpack output or Promise when nodeOptions are present