How To Test A Custom Module Running Node-fluent-ffmpeg (an Async Module)?
How do I test a custom module which is simply running a node-fluent-ffmpeg command with Mocha&Chai? // segment_splicer.js var config = require('./../config'); var utilities = r
Solution 1:
This test should be passing.
A test will only fail if you either assert or expect something in the test which is not true, or if the subject under test throws an uncaught error.
You are not asserting anything in your test, and the only error your subject will throw is if you pass less than 2 arguments, which is not the case in your test.
The ffmpeg
method also seems to be asynchronous, which is not compatible with the way you have structured your test.
There are many examples available on setting up async tests, including:
- How Mocha Makes Testing Asynchronous JavaScript Processes Fun
- Asynchronous Unit Tests With Mocha, Promises, And WinJS
- Testing Asynchronous JavaScript
You've gone some way to doing this by referencing the done
argument. When this is specified, Mocha will wait until it is called before considering the test finished.
Post a Comment for "How To Test A Custom Module Running Node-fluent-ffmpeg (an Async Module)?"