问题标签 [grunt-jest]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
reactjs - How do I debug Jest's preprocessor?
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:
Preprocessor file:
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.)
javascript - AppDispatcher 没有开玩笑地注册商店
我正在尝试使用 jest 测试商店,但它没有注册 AppDispatcher。第一个注释行包括jest.mock
允许 console.log 输出一个空的{ calls: [], instances: [] }
. 我不想明确地调用它,因为 jest 应该自动模拟所有需求。为什么是AppDispatcher.register.mock
未定义的?我先提供了商店代码,然后是测试。谢谢!
商店代码。
测试代码。
javascript - 开玩笑点击innerHTML: TypeError: undefined is not a function
我正在尝试模拟 DOM 的单击事件,但由于某些有趣的原因,它不起作用。
将事件附加到给定的 a 元素似乎是有效的,但是单击该元素只会一直诅咒我。
我在这里有什么概念上的错误吗?
这是一个在浏览器中工作的示例,但在运行 grunt jest 时不能:
解决方案:
由于 jest-cli 0.4.19 确实有这么古老的 jsdom 版本(~0.10.3),您需要使用已弃用的 Javascript 方法,例如.initEvent
. 像这样的适当的事件创作是let evt = new MouseEvent('click');
行不通的。
`