-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update location of defaultPropTestParams to not accidentally pull in …
…jest
- Loading branch information
Showing
3 changed files
with
31 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as fc from 'fast-check'; | ||
|
||
export function defaultPropTestParams<T = unknown>(): fc.Parameters<T> { | ||
const baseParams = { | ||
numRuns: Number(process.env.AZLE_PROPTEST_NUM_RUNS ?? 1), | ||
reporter: (runDetails: fc.RunDetails<T>): void => { | ||
const seed = runDetails.seed; | ||
const path = runDetails.counterexamplePath; | ||
const reproductionCommand = `AZLE_PROPTEST_SEED=${seed}${path !== null ? ` AZLE_PROPTEST_PATH="${path}"` : ''} AZLE_VERBOSE=true AZLE_TEMPLATE=true npm test`; | ||
const reproductionMessage = `To reproduce this exact test case, run:\n${reproductionCommand}`; | ||
console.info(reproductionMessage); | ||
if (runDetails.failed) { | ||
throw new Error( | ||
`${reproductionMessage}\n\n${fc.defaultReportMessage(runDetails)}` | ||
); | ||
} | ||
}, | ||
endOnFailure: process.env.AZLE_PROPTEST_SHRINK === 'true' ? false : true | ||
}; | ||
|
||
const seed = | ||
process.env.AZLE_PROPTEST_SEED !== undefined | ||
? Number(process.env.AZLE_PROPTEST_SEED) | ||
: undefined; | ||
|
||
const path = process.env.AZLE_PROPTEST_PATH; | ||
|
||
return seed !== undefined ? { ...baseParams, seed, path } : baseParams; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters