mocha-param
mocha-param copied to clipboard
Proposal: describe-included syntax
I find myself often writing tests like this:
describe(*name*, function() {
itParam(*name*, [ data ], function() {
// ...
})
// no other tests
})
I'd propose to add a way to call itParam with a describe call "included", like this:
itParam(*describe name*, *test name*, [ data ], function() { // test name would probably be using ${value}
// ...
})
Although, that syntax might be a mess to parse due to the absence of overloads in JavaScript. Perhaps something like this would be easier:
itParam.describe(*describe name*, *test name*, [ data ], function() { // test name would probably be using ${value}
// ...
})
I agree with your concern. But I think the first param could be a string or a config object.
This allow multiples describe nesting:
itParam({
describe: {
description: "outer describe description using value",
it: "test description using value",
describe: {
description: "inner describe description using value",
it: "another test description using value"
}
}
}, [ data ], ( ) => {
// ...
})
Or maybe an introduction of describeParam:
describeParam(
"Describe description for ${value.outerDescribeDescription}",
[ data ],
describeParam(
"Describe description for ${value.innerDescribeDescription}",
value, // Data object could be used like this or could be injected by the upper describeParam
itParam("test description ${value.itDescription}", value, ( ) => {
// ...
})
)
)