Repository navigation
Description
I just ran into this scenario, which I suspect is pretty common: while testing an object (a subclass of Set), I wanted to test both the values as well as value type (to make sure it was the subclass I was defining and not Set).
One potential solution is to make check() take an array, in which case multiple tests are generated, one for each check.
One tricky bit is that what happens if you want to specify a map() function on only some of them?
Perhaps the solution would be to just utilize nesting which already works:
export default {
// test params here
tests: [
// all parent params inherited, so we only specify what changes
{check: check.is("MyFoo")],
{map: v => [...v]}
],
}However, this doesn't scale when you have multiple tests.
It seems this is another instance of the more general problem "You have M and Ns and you want to test every combination of M x N", which is also the subject of #106 .
I wonder if the right solution might be some way to basically automate the nested solution, i.e. provide tests that will be automatically added to all leafs under a certain group.
E.g. assuming we call that property leafTests (to be bikeshedded) this means one can do:
export default {
run (arg) {
return arg + 1;
},
expect: 1,
leafTests: [
{ /* default equality check */ }
{ check: check.is("number") }
],
tests: [
{ arg: 1 }
{ arg: Number("1") },
{ arg: new Number("1") },
],
}Which will basically be a macro for doing:
const leafTests = [
{ /* default equality check */ }
{ check: check.is("number") }
];
export default {
run (arg) {
return arg + 1;
},
expect: 1,
tests: [
{ arg: 1, tests: leafTests }
{ arg: Number("1"), tests: leafTests },
{ arg: new Number("1"), tests: leafTests },
],
}And note that given how nesting works, either of these can be nested, and it should just work.
This allows people providing multiple sets of not just checking functions, but also data, run(), basically any key we support.
I think I'm becoming convinced this is the way to go, but we need to find a good name for this concept.
Some ideas:
checks(since in most cases this will be about check/map)childTestsautoChildrenforEacheachcross(since this is basically doing a cross-product)crossTestswithwithTests
Activity
Zearin commentedon Dec 13, 2025
−1 for:
checkscheck.and(), which is not what this does)childTestschildTestswould create confusion, since you can already nesttestsas much as you likeautoChildrenforEachforEach)eachwithforEachforEach(),withis universally discouraged, so maybe fewer people have an existing association for the wordwithTeststests, sowithTestsmakes me wonder something like, “Does this mean that I’m using regulartestswrong, or inefficiently?”+1 for:
crossTeststests. So this name is descriptive for 2 totally different ways brain types/thinking styles, each getting an accurate “gut sense” of what this might do.