Reasonml/Rescript bindings for the Detox end-to-end testing framework. See here for a complete example project using this library.
- you are using reason-react-native and want to write end-to-end test's without introducing js
- you are using plain old React Native and want to try introducing Reasonml in a lightweight way
- experimental but definitely usable, building blocks are there just needs a few more primitives adding
- install detox for jest as per the standard instructions
- ensure you can successfully run a standard detox test before continuing
- install reason-detox
yarn add --dev jest @glennsl/bs-jest bs-let https://github.com/alltonp/reason-detox
- in
bsconfig.json
- add
"@glennsl/bs-jest", "reason-detox"
to"bs-dependencies"
- add
"ppx-flags": ["bs-let/ppx"]
- add to
"sources"
:
{ "dir": "e2e", "type": "dev" }
- add
- update
e2e/config.json
with:"testRegex": "\\Test\\.bs.js$", "transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|react-(native|universal|navigation)-(.*)|@react-native-community/(.*)|@react-navigation/(.*)|bs-platform|(@[a-zA-Z]+/)?(bs|reason|rescript)-(.*)+)" ]
- that's it!
- save the following in
e2e/firstTest.re
open Jest;
open ReasonDetox;
describe("The Test", () => {
testPromise("example", _ => {
//TIP: everything that returns a Promise must use let%Await
let%Await _ = expect(Id("count")) |> toHaveText("0");
let%Await _ = tap(Text("+"));
let%Await _ = expect(Id("count")) |> toHaveText("1");
let%Await _ = tap(Text("-"));
let%Await _ = expect(Id("count")) |> toHaveText("0");
//TIP: must call this at the end to tell jest we are done, otherwise the test will run until timeout and then fail
Js.Promise.resolve(pass);
})
});
detox test -f e2e/firstTest.bs.js
detox test