@flemist/html-css-dev
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

NPM Version NPM Downloads Build Status Test Coverage

Runs a test function with all possible combinations of its parameters.

Usage

Sync only

const result = []
const testVariants = createTestVariants(({a, b, c}: { a: number, b: string, c: boolean }) => {
    result.push([a, b, c])
})
const count = await testVariants({
    a: [1, 2],
    b: ['3', '4'],
    c: [true, false],
})({
  pauseInterval: 10000, // pause after each 10 seconds and log inerations count, it needed for karma tests
  pauseTime: 10, // continue after 10 milliseconds
})

// result == [
//     [1, '3', true],
//     [1, '3', false],
//     [1, '4', true],
//     [1, '4', false],
//     [2, '3', true],
//     [2, '3', false],
//     [2, '4', true],
//     [2, '4', false],
// ]
// count == 8

Async

const result = []
const testVariants = createTestVariants(async ({a, b, c}: { a: number, b: string, c: boolean }) => {
  await delay(10)
  result.push([a, b, c])
})
const count = await testVariants({
    a: [1, 2],
    b: ['3', '4'],
    c: [true, false],
})() // no extra parameters

Calculable variants

const result = []
const testVariants = createTestVariants(async ({a, b, c}: { a: number, b: number, c: number }) => {
  await delay(10)
  result.push([a, b, c])
})
const count = await testVariants({
    a: [1, 2],
    b: ({a}) => [ a + 1, a + 2 ], // you can use 'a', but you can't use 'c' because it will initialize after 'b' 
    c: ({a, b}) => [ a, b, a + b ],
})()

License

Unlimited Free

Readme

Keywords

Package Sidebar

Install

npm i @flemist/html-css-dev

Weekly Downloads

0

Version

2.1.0

License

Unlimited Free

Unpacked Size

95.3 kB

Total Files

45

Last publish

Collaborators

  • nikolay_makhonin