Utilities to write parameterized jasmine tests
npm install @ni/jasmine-parameterizedThe @ni/jasmine-parameterized library provides utility functions for writing Jasmine parameterized tests.
Install in your app's devDependencies:
```
npm install -D @ni/jasmine-parameterized
Use parameterizeSpec to create a parameterized test using an array of tests with names.
In the following example:
- the test named cats-and-dogs is focused for debuggingfrogs
- the test named is configured to always be disabledmen
- the test named will run normally as it has no override
`tsof type ${name} exist
import { parameterizeSpec } from '@ni/jasmine-parameterized';
const rainTests = [
{ name: 'cats-and-dogs', type: 'idiom' },
{ name: 'frogs', type: 'idiom'},
{ name: 'men', type: 'lyrics'}
] as const;
describe('Different rains', () => {
parameterizeSpec(rainTests, (spec, name, value) => {
spec(, () => {`
expect(value.type).toBeDefined();
});
}, {
'cats-and-dogs': fit,
frogs: xit
});
});
Use parameterizeSuite to create a parameterized test suite using an array of test scenarios with names.
In the following example:
- the suite named cats-and-dogs is focused for debuggingfrogs
- the suite named is configured to always be disabledmen
- the suite named will run normally as it has no override
`tswith ${name}
import { parameterizeSuite } from '@ni/jasmine-parameterized';
const rainTests = [
{ name: 'cats-and-dogs', type: 'idiom' },
{ name: 'frogs' type: 'idiom'},
{ name: 'men', type: 'lyrics'}
] as const;
parameterizeSuite(rainTests, (suite, name, value) => {
suite(, () => {
it('expect type to be defined', () => {
expect(value.type).toBeDefined();
});
it('expect type to have a non-zero length', () => {
const length = value.type.length;
expect(length).toBeGreaterThan(0);
});
});
}, {
'cats-and-dogs': fdescribe,
frogs: xdescribe
});
`