-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get working with rescript-jest
?
#8
Comments
hmm, I don't use jest (I'm not really a fan) but I am aware the We can't make changes to A new project could be built around both |
Looking at This meshes with what I was thinking, that So really the main thing you need is a way to convert my |
@TheSpyder My colleague @Hazelfire figured out that this dead simple strategy technically works, it raises failures when the property is incorrect. open Jest
open FastCheck
open Arbitrary
open Property.Sync
// Code under test
let contains = (text, pattern) => text->Js.String2.indexOf(pattern) >= 0
// Properties
describe("properties", () => {
// string text always contains itself
test("should always contain itself", () => {
assert_(property1(string(), text => contains(text, text)))
pass
})
// string a + b + c always contains b, whatever the values of a, b and c
test("should always contain its substrings", () => {
assert_(
property3(string(), string(), string(), (a, b, c) =>
contains(a ++ b ++ c, b)
)
)
pass
})
}) |
That's a pretty good way to do it for sure. The only way to make that easier would be something that avoided the need for a Side note, instead of |
The main bottleneck to working with
rescript-jest
is thatpropertyk
functions expect predicates to returnbool
, whereas theExpect
module fromrescript-jest
deals in the typeJest.assertion
.Are there any quick ideas to get up and running? Alternatively, what would a PR look like?
Edit: it doesn't look like there should be a bottleneck here because according to the examples
expect
works right out of the box withfast-check
in javascript.The text was updated successfully, but these errors were encountered: