Skip to main content

Parametrised Tests

Parametrised Tests

import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params({ arg1: 'bar', arg2: 'foo' }, 'custom test name')
test({ arg1, arg2 }) {
}
}

Run Tests

npm test

...

Suite
test
test 0
✓ custom test name

...

Parametrised Test Naming

import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' }, 'a custom test name')
@params({ arg1: 'bar', arg2: 'foo' })
@params.naming(({ arg1, arg2 }) => `test foobar against ${arg1} and ${arg2}`)
test({ arg1, arg2 }) {
}
}

Run Tests

npm test

...

Suite
test
✓ a custom test name
test foobar against bar and foo

...

Pending Parameter Sets

import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params.pending({ arg1: 'bar', arg2: 'foo' }, 'SUT does not yet support this')
"test foobar against parameters"({ arg1, arg2 }) {
}
}

Run Tests

npm test

...

Suite
test foobar against parameters
test foobar against parameters 0
- SUT does not yet support this

...

Skipping Parameter Sets

import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params.skip({ arg1: 'bar', arg2: 'foo' }, 'test fails on this, no time fixing')
test({ arg1, arg2 }) {
}
}

Run Tests

npm test

...

Suite
test
test 0
- test fails on this, no time fixing

...

Focused Parameter Set Testing

import { suite, params } from '@testdeck/mocha';

@suite
class Suite {

@params({ arg1: 'foo', arg2: 'bar' })
@params.only({ arg1: 'bar', arg2: 'foo' }, 'should be fixed now...')
test({ arg1, arg2 }) {
}
}

Run Tests

npm test

...

Suite
test
✓ should be fixed now...

...
Morty Proxy This is a proxified and sanitized view of the page, visit original site.