Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dflor003/jasmine-rowtests
This simple jasmine plugin allows you to create multiple specs based off of different test data (i.e. row tests).
https://github.com/dflor003/jasmine-rowtests
Last synced: 3 days ago
JSON representation
This simple jasmine plugin allows you to create multiple specs based off of different test data (i.e. row tests).
- Host: GitHub
- URL: https://github.com/dflor003/jasmine-rowtests
- Owner: dflor003
- License: mit
- Created: 2012-10-17T17:52:49.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-06-22T19:29:51.000Z (over 11 years ago)
- Last Synced: 2024-10-12T13:28:27.622Z (about 1 month ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# jasmine-rowtests
This [Jasmine JS](https://github.com/pivotal/jasmine) plugin allows you to test one spec against multiple possible data inputs and will generate a unique spec for each input row.
## Installation
1. Download jasmine-rowtests
2. Place the file somewhere your Jasmine Specrunner can reference.
3. Include jasmine-rowtests.js after you include jasmine.js
4. Begin using it in tests! (See usage details below)## Usage
Creating row tests is pretty straight forward via the global `given(...)` function and chaining that onto an `it(params)` function. jasmine-rowtests supports two main ways of specifying row tests. For simple, one-paramter row tests, you can pass a single array to the `given(...)` function that contains one item per row as in the following example:
```js
describe('My module', function() {
given([
null,
undefined,
'',
0,
false])
.it('should be falsy', function(value) {
expect(value).toBeFalsy();
});
});
```To create row tests for multi-parameter specs, pass an array with one array per row of parameters as in the following example:
```js
describe('My module', function() {
given([
[true, false],
[5, 0],
[true, 0],
['test', '']
])
.it('should be greater than', function(first, second) {
expect(first).toBeGreaterThan(second);
});
});
```This will generate one spec per row in your row test such as the following:
```
My module
given (null) - should be falsy
given (undefined) - should be falsy
given ('') - should be falsy
given (0) - should be falsy
given (false) - should be falsy
given (true, false) - should be greater than
given (5, 0) - should be greater than
given (true, 0) - should be greater than
given ('test', '') - should be greater than
```