How do you detox test offline mode

215 Views Asked by At

We're developing a react native app and building automated testing with detox on CI. I am wondering how to test the offline mode of the app with detox ? Has anyone already tried this ?

1

There are 1 best solutions below

0
R1' On

I found a workaround for android emulator :

export function setNetworkConnection(boolean: boolean) {
    child.exec(
        "adb shell svc data " +
            `${boolean ? "disable;" : "enable;"}` +
            "adb shell svc wifi " +
            `${boolean ? "disable;" : "enable;"}`,
        function (error, stdout, stderr) {
            if (error !== null) {
                console.log(stdout, stderr);
                console.log("child.exec error: " + error);
            }
        }
    );
}