I would still say that you can enforce an order, you can say that you should always use skipIf
first and not after the functions that change the signature, like each
. You’d have to define different each
functions depending on the number of elements it has anyway.
I would definitely model it like this playground link:
type test = (string, unit => unit) => unit
@module("vitest") external test: test = "test"
@send external skipIf: (test, bool) => test = "skipIf"
@send
external each3: (
test,
array<('a, 'b, 'c)>,
) => (string, ('a, 'b, 'c) => unit) => unit = "each"
type expect<'a>
@module("vitest") external expect: 'a => expect<'a> = "expect"
@send external toBe: (expect<'a>, 'a) => unit = "toBe"
test("1+1 = 2", () => expect(1 + 1)->toBe(2))
skipIf(test, isDev)("1+1 = 2", () => expect(1 + 1)->toBe(2))
each3(test, [(1, 2, 3), (3, 4, 7)])("add(%i, %i) -> %i", (a, b, c) =>
expect(a + b)->toBe(c)
)
The only issue I could find comes from the fact there seems to be a bug with the fast pipe and uncurried mode, so you wouldn’t be able to pipe test
to each3
or skipIf
, which is definitely unfortunate, but hopefully can be fixed.