我如何调试 Jest 的预处理器?

How do I debug Jest's preprocessor?

有时我需要调整我的 preprocessor.js 以说明不应通过 ReactTools.transform 的新文件类型。我想调试对 process 的调用以确保我理解它的参数 - 但是如果我在方法中 console.log 我得到这个错误:

Error: Attempted to send a message to the worker before the response from the last message was received! Worker processes can only handle one message at a time.

我是 运行 来自 Grunt 的 Jest,来自 grunt-jest。 Gruntfile 部分:

jest: {
  options: {
    coverage: false,
    testPathPattern: /__tests__\/.*/
  }
},

预处理器文件:

'use strict';
var ReactTools = require('react-tools');

module.exports = {

  process: function(src, file) {
    if (file.match(/node_modules/)) {
      return src;
    } else if (file.match(/css/)) {
      return '';
    } else if (file.match(/png/)) {
      return '';
    }
    //console.log/setTimeout...console.log doesn't work
    //console.log(file);
    //setTimeout(function() {console.log(file);},0);

    var transformed = ReactTools.transform(src, { harmony: true });

    return transformed;
  }

};

Relevant docs from jest

如何调试 'process' 方法?

(我试图调试的问题是需要 node_modules 中的 css 文件,该文件被第一个 if 块捕获并且从未到达 .match(/css/) 块,但是问题仍然存在。)

我之前也曾 运行 参与过,但无法找出原因,但我的解决方法是只使用 console.warn 代替。