Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjirou/mocha-automatic-coffeemaker
Generate a test code of mocha by the same path structure
https://github.com/kjirou/mocha-automatic-coffeemaker
Last synced: 12 days ago
JSON representation
Generate a test code of mocha by the same path structure
- Host: GitHub
- URL: https://github.com/kjirou/mocha-automatic-coffeemaker
- Owner: kjirou
- License: mit
- Created: 2015-10-04T07:03:03.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T16:34:17.000Z (about 3 years ago)
- Last Synced: 2024-09-19T15:48:18.720Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mocha-automatic-coffeemaker
[![npm version](https://badge.fury.io/js/mocha-automatic-coffeemaker.svg)](http://badge.fury.io/js/mocha-automatic-coffeemaker)
[![Build Status](https://travis-ci.org/kjirou/mocha-automatic-coffeemaker.svg?branch=master)](https://travis-ci.org/kjirou/mocha-automatic-coffeemaker)Generate a test code of [mocha](https://www.npmjs.com/package/mocha) by the same path structure
## Installation
```bash
npm install -g mocha-automatic-coffeemaker
```## Example
There is a targeted file of testing:
```bash
$ tree ./lib
lib
└── util.js
```Generate a mocha's test code:
```bash
$ genmochatest lib/utils.js
Generated successfully!
root: /home/username/your-project
src : lib/utils.js
test: test/lib/utils.js
$ cat test/lib/utils.js
describe('lib/utils', function() {
});
```## Usage
```
$ genmochatest [options]A file path of the code that you want to write a test
e.g.
lib/foo.js
/path/to/lib/x/y/foo.js[options]
--dirname, -d
Default: 'test'--extensions, -e
Default: 'js,es,es6,es7,coffee,ts,jsx'--force, -f
Default: false
Overwrite a test code, even if it already exists--omission, -o
Default: null
Excluded from the path in front match at the time of test generation--root, -r
Default: process.cwd()--template, -t
Default: process.cwd() + '/mocha-automatic-coffeemaker-template.js'
```Default options can also be defined in the package.json:
```
"mocha-automatic-coffeemaker": {
"dirname": "spec",
"force": true
},
```## Template Example
You can specify the template of test code like the following code:
```js
module.exports = function(data) {// e.g. "foo/bar/baz.js"
var filePath = data.filePath;
// e.g. "foo/bar/baz"
var noExtensionFilePath = data.noExtensionFilePath;
// e.g. "baz.js"
var fileName = data.fileName;
// e.g. "baz"
var noExtensionFileName = data.noExtensionFileName;// e.g. If you specified `--omission bar`, then it assigned "foo/baz.js"
var omittedFilePath = data.omittedFilePath;
var noExtensionOmittedFilePath = data.noExtensionOmittedFilePath;return [
"describe('" + noExtensionFilePath + "', function() {",
"});",
].join('\n');
};
```