Replies: 1 comment
-
|
Not sure how to do that "properly". But a simple alternative could be to put the test into a function, which takes function myModelTest(seedEtc, replayPath) {
fc.assert(
fc.property(
fc.nat(),
fc.integer(),
fc.commands(MyCommandList, { replayPath }),
(v1, v2, cmds) => {
const s = () => { model: whatever(v1, v2), real: whatever(v1, v2) };
fc.modelRun(s, cmds);
}
),
seedEtc,
)
}And then create test for a list of example seed/replayPath combinations: test('randomized', () => {
myModelTest(undefined, undefined)
})
const examples = [
[{ seed: 335168591, path: "0:0", replayPath: ":" }],
// ...
]
// foreach-loop to create test for each example:
for (const { seed, path, replayPath } of examples) {
test('example', () => {
myModelTest({ seed, path, endOnFailure: true }, replayPath)
})
}
// or with `test.each` if you are using Jest/Vitest/...
test.each(examples)('example', ({ seed, path, replayPath }) => {
myModelTest({ seed, path, endOnFailure: true }, replayPath)
})A downside is that the saved examples can become un-replayable if underlying arbitraries are changed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Normally when fast-check identifies an error in my code, I add the specific failing example to an
examplesarray so that known failure case always gets covered.I'm trying to do the same with some model-based testing, but I end up with type errors because it expects
cmdsto beIterable<fc.Command<Model, Real>>. The output of my failing test doesn't provide a value for this property, just any other properties I gave. For example:Might give me an output like:
I know that I need to use the
replayPathto re-run this using theseed, but how do I do it as one of several discreteexamples? Should I just intercept it with the debugger and construct the array myself?Beta Was this translation helpful? Give feedback.
All reactions