0

Occasionally I need to tweak my preprocessor.js to account for a new file type that shouldn't go through ReactTools.transform. I'd like to debug the calls to process to make sure I understand its arguments - however if I console.log within the method I get this error:

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.

I am running Jest from Grunt via grunt-jest. Gruntfile section:

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

Preprocessor file:

'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

How can I debug the 'process' method?

(The problem I was trying to debug was requiring a css file in node_modules which was caught by the first if block and never got to the .match(/css/) block, but the question still stands.)

4

1 回答 1

0

我以前也遇到过这种情况,无法找到原因,但我的解决方法是console.warn改用它。

于 2015-05-12T21:06:39.310 回答