开玩笑 - 手表模式错误

jest - error with watch mode

我正在使用 Jest 21.2.1 来 运行 我对反应应用程序的测试。奇怪的是,当我运行 jest --watch(如前所述here)观察测试用例的任何变化时,我得到如下错误

Determining test suites to run...Error: This promise must be present when running with -o.

我尝试检查 Jest-CLI,发现该函数需要两个参数,其中一个是 promise,在这种情况下未传递(不确定如何传递)。也许缺少一些配置?

任何建议都有助于解决此问题。

getTestPaths(
  globalConfig,
  changedFilesPromise)
  {var _this2 = this;return _asyncToGenerator(function* () {
     const paths = globalConfig.nonFlagArgs;
     if (globalConfig.onlyChanged) {
        if (!changedFilesPromise) {
           throw new Error('This promise must be present when running with -o.');
        }

        return _this2.findTestRelatedToChangedFiles(changedFilesPromise);
     }

注意:这可能与报告的问题 here 有关。

确保您运行将它放在 Git 存储库中(用 git init 初始化)。否则它不知道如何只获取更改的文件。

如果您不想 运行 仅对更改的文件进行测试,您可以使用 --watchAll,其中 运行 包含所有测试。