dflynn15 / gulp-jasmine-phantom

Gulp plugin to run Jasmine tests with Phantom or mininodejasmine2.
27 stars 30 forks source link

TypeError: "Callback must be a function" #79

Open CodeWithOz opened 6 years ago

CodeWithOz commented 6 years ago

node version: 10.6.0

This error caused my scripts to always exit even before the tests could start being checked. This was the stack trace:

[11:29:44] Starting 'tests'...
[11:29:44] Running Jasmine with PhantomJS
[11:29:46] 'tests' errored after 2.42 s
[11:29:46] TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at makeCallback (fs.js:141:11)
    at Object.unlink (fs.js:912:14)
    at cleanup (C:\Users\ucheo\Projects\NDBuildTools\Lesson 3\node_modules\gulp-jasmine-phantom\index.js:45:6)
    at C:\Users\ucheo\Projects\NDBuildTools\Lesson 3\node_modules\gulp-jasmine-phantom\index.js:87:7
    at ChildProcess.exithandler (child_process.js:298:5)
    at ChildProcess.emit (events.js:182:13)
    at ChildProcess.EventEmitter.emit (domain.js:460:23)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

My Current (and Proposed) Solution I found a similar issue in the Grunt version of this plugin and implemented the solution given there. In other words, I used the stack trace to locate the erroneous call to the unlink method in the cleanup function's definition and replaced fs.unlink(path) with fs.unlinkSync(path). I did not test this fix in other versions of node because the OP said he performed those tests and they worked; he also noted that the unlinkSync method has been around since v0.1.21 so I expect that this will not be a breaking change.