February 2019
Beginner to intermediate
180 pages
4h 4m
English
In this chapter, we learned the basics of setting up bs-jest with both the CommonJS and ES Module formats. We also learned that unit testing can help force us to write better code because, for the most part, code that is easier to test is also better. We refactored getCustomer to getCustomerById, and moved the array of customers into that component's state.
Since we've written our unit tests in Reason, the compiler checks our tests as well. For example, if Customer_test.re uses getCustomer and we change getCustomerById to getCustomer in Customer.re, we get a compile time error:
We've found a bug for you!/__tests__/Customers_test.re 45:9-2843 |];44 let customer: CustomerType.t =45 Customer.getCustomer(customers, 2) |> Belt.Option.getExn; ...
Read now
Unlock full access