2015-05-12 66 views
0

偶尔我需要调整我的preprocessor.js来解释不应该经历ReactTools.transform的新文件类型。我想调用调试到process,以确保我的理解它的参数 - 但是如果我console.log的方法我得到这个错误中:如何调试Jest的预处理器?

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运行玩笑。 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

如何调试的 '过程' 的方法?

(我试图调试的问题,需要在node_modules一个CSS文件这是由第一个抓到,如果块未曾到达的.match(/css/)块,但问题仍然有效。)

回答

0

我已经运行进入之前,也无法追查为什么,但我的工作是只使用console.warn来代替。

+0

完美,谢谢!我仔细研究了一下,因为'console.warn' /'console.error'打印到stderr而不是stdout(这是'console.log'和'console.info'打印的地方)。 https://nodejs.org/api/console.html#console_console_error_data – pherris