Parametrised Tests

1
2
3
4
5
6
7
8
9
10
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
    testtest 0
      ✓ custom test name

...

Parametrised Test Naming

1
2
3
4
5
6
7
8
9
10
11
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

1
2
3
4
5
6
7
8
9
10
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

1
2
3
4
5
6
7
8
9
10
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
    testtest 0
      - test fails on this, no time fixing

...

Focused Parameter Set Testing

1
2
3
4
5
6
7
8
9
10
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...

...