grunt-mock
The grunt task is used to execute the specified mock-functions and save the result
In a unit test, mock objects can simulate the behavior of complex, real objects and are therefore useful when a real object is impractical or impossible to incorporate into a unit test.
Getting Started
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-mock --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
grunt-mock task
Run this task with the grunt mock
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Usage Example
module { grunt; grunt; grunt;};
Input file
moduleexports = { return 1; } { return 2; };
Output file
"mock#1": 1 "mock#2": 2
Options
process
Type: Function (data, original)
Default: (data, original) => original;
This option as an advanced way to control the file contents that are created.
module { grunt; grunt; grunt;};
Input file
moduleexports = { return 1; } { return 2; };
Output file
"mock#1": 1 "mock#2": 2
Tests
grunt test
License
MIT
Links
Task submitted by Alexander Abashkin