0.3.0 • Published 8 days ago

@ni/jasmine-parameterized v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

Jasmine Parameterized

The @ni/jasmine-parameterized library provides utility functions for writing Jasmine parameterized tests.

Usage

  1. Install in your app's devDependencies:

    npm install -D @ni/jasmine-parameterized
  2. Use parameterizeSpec to write strictly-typed jasmine tests that run for different test scenarios, where each test can be focused or excluded as needed by name.

parameterizeSpec

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 debugging
  • the test named frogs is configured to always be disabled
  • the test named men will run normally as it has no override
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(`of type ${name} exist`, () => {
            expect(value.type).toBeDefined();
        });
    }, {
        'cats-and-dogs': fit,
        frogs: xit
    });
});

parameterizeSuite

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 debugging
  • the suite named frogs is configured to always be disabled
  • the suite named men will run normally as it has no override
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(`with ${name}`, () => {
        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
});
0.3.0

8 days ago

0.2.4

19 days ago

0.2.3

2 months ago

0.2.2

2 months ago

0.2.1

3 months ago

0.2.0

3 months ago