I have a node.js application that has the main process main-process.js and the child process child-process.js . main-process.js looks like this:
var childProcess = require('child_process'); var job = childProcess.spawn('node', ["child-process.js"], { detached = true, stdio: ['ipc'] });
My child-process.js performs some task and notifies the parent process of its status, uses
exports.init = function() {
Now I want unit test child-process.js to use jasmine-node. But when I call the init() method from the specification, the jasmine-node throws an error saying
TypeError: Object #<process> has no method 'send'
Is there a way to mock the process variable? In other words, how to make unit test this script?
Srivathsa
source share