jasmine-cookies
v0.1.3
Published
Jasmine helpers
Downloads
20
Readme
Jasmine Cookies
Jasmine Cookies is a module with several helper functions.
It
This helper is a wrapper around jasmine it
which adds user-friendly filtering. Test will be launched only in case if test name passes filtering expression (if no expression provided all tests will run by default).
Code sample:
const Test = require("jasmine-cookies");
Test.Describe("...", () => {
Test.It('test id 101', async () => {
...
});
});
Filter expression samples:
`Test.conditionalFilter("foo OR bar")` // choose only tests which name contains 'foo' and 'bar'
`Test.conditionalFilter('"hello world" OR bar')` // choose only tests which name contains 'hello world' and 'bar'
`Test.conditionalFilter("foo OR ( bar AND id )")` // choose only tests which name contains 'foo' or (contains 'bar' and contains 'id')
`Test.conditionalFilter("foo | ( bar & !id )")` // choose only tests which name contains 'foo' or (contains 'bar' and don't contains 'id')
`Test.conditionalFilter("foo OR bar")` // choose only tests which name contains 'foo' or 'bar'
`Test.conditionalFilter("NOT foo OR bar")` // choose only tests which name don't contains 'foo' or contains 'bar'
Note:
Test.conditionalFilter(...)
should be called before anyIt
orpIt
, or it can be set in environment variableJASMINE_COOKIES_FILTER
- special characters (
| & !
) are now allowed in text (i.e.Test.conditionalFilter('"hello world!"')
is not valid expression) - filter expression will be applied to concatenated
Describe
andIt
/pIt
descriptions, DO NOT USE 'raw' jasminedescribe
withIt
's!
pIt
This helper is a wrapper around jasmine it
which adds parametrized testing (when same test performs on multiple data sets). Basically pIt
performs data processing and run It
on each data set using description
property as test name.
Possible data sources:
any[]
- javascript objects array- code sample:
const Test = require("jasmine-cookies"); const pIt = Test.pIt; const dataSource = [ { description: 'test 1', a: 1, b: 2}, { description: 'test 2', a: 3, b: 4}, { description: 'test 3', a: 5, b: 6} ]; pIt({data: {type: TestDataSourceType.DATA_ARRAY, source: dataSource}}, async (params) => { console.log(`params.a is ${params.a}`); console.log(`params.b is ${params.b}`); });
- output:
"test 1" params.a is 1 params.b is 2 "test 2" params.a is 3 params.b is 4 "test 3" params.a is 5 params.b is 6
- code sample:
json
from json file- code sample:
const path = require("path"); const Test = require("jasmine-cookies"); const pIt = Test.pIt; const jsonPath = path.resolve('./path_to_json_file.json'); //convert relative path to absolute pIt({data: {type: TestDataSourceType.DATA_ARRAY, source: require(jsonpath)}}, async (params) => { ... });
- code sample:
xlsx/xlsm
- using Excel tables as a source. Excel table transforms json usingxlsx
andcsv-to-deep-json
libs:- code sample:
const path = require("path"); const Test = require("jasmine-cookies"); const filePath = path.resolve('./file/path/to/sheet.xlsx'); //convert relative path to absolute Test.pIt({data: {type: TestDataSourceType.XLSX, xlsxFilePath: filePath}}, async (params) => { ... });
- code sample: