Repository: wix/Detox
Pull request #2629 (2021-02-05 22:24:24)

feat(types): add function toHaveToggleValue
<!---
Thank you for contributing!
Before submitting a pull request that implements a new functionality or fixing a major bug,
please open an issue first and propose your solution. This way we can discuss before time is 
spent on a solution that may not work for us.

Please check the correct option in the below list and delete the irrelevant one.
For the second option, please fill the issue where the solution has been discussed.
-->

- [x] This is a small change 
- [ ] This change has been discussed in issue #<?> and the solution has been agreed upon with maintainers.

---

**Description:**

- Added missing function `toHaveToggleValue` to `Expect` interface.
- Fix some typos in index.d.ts file.


Patch:
diff --git a/detox/index.d.ts b/detox/index.d.ts
index 6964a51a8..e61cd9d9a 100644
--- a/detox/index.d.ts
+++ b/detox/index.d.ts
@@ -74,7 +74,7 @@ declare global {
                  * set this property to `false`.
                  *
                  * This is useful when during E2E tests you also need to run regular expectations
-                 * in Node.js. Jest's `expect` for instance, will not be overriden by Detox when
+                 * in Node.js. Jest's `expect` for instance, will not be overridden by Detox when
                  * this option is used.
                  */
                 exposeGlobals?: boolean;
@@ -262,7 +262,7 @@ declare global {
              * set this property to `false`.
              *
              * This is useful when during E2E tests you also need to run regular expectations
-             * in Node.js. Jest's `expect` for instance, will not be overriden by Detox when
+             * in Node.js. Jest's `expect` for instance, will not be overridden by Detox when
              * this option is used.
              */
             initGlobals?: boolean;
@@ -363,7 +363,7 @@ declare global {
              */
             setLocation(lat: number, lon: number): Promise<void>;
             /**
-             * Disable EarlGrey's network synchronization mechanism on preffered endpoints. Usful if you want to on skip over synchronizing on certain URLs.
+             * Disable EarlGrey's network synchronization mechanism on preferred endpoints. Useful if you want to on skip over synchronizing on certain URLs.
              *
              * @example await device.setURLBlacklist(['.*127.0.0.1.*']);
              */
@@ -556,10 +556,16 @@ declare global {
             toHaveLabel(label: string): R;
             /**
              * In React Native apps, expect UI component to have testID with that id.
-             * In native iOS apps, expect UI element to have accesibilityIdentifier with that id.
+             * In native iOS apps, expect UI element to have accessibilityIdentifier with that id.
              * @example await expect(element(by.text('I contain some text'))).toHaveId('UniqueId204');
              */
             toHaveId(id: string): R;
+            /**
+             * Expects a toggle-able element (e.g. a Switch or a Check-Box) to be on/checked or off/unchecked. 
+             * As a reference, in react-native, this is the equivalent switch component.
+             * @example await expect(element(by.id('switch'))).toHaveToggleValue(true);
+             */
+            toHaveToggleValue(value: boolean): R;
             /**
              * Expect components like a Switch to have a value ('0' for off, '1' for on).
              * @example await expect(element(by.id('UniqueId533'))).toHaveValue('0');
@@ -680,7 +686,7 @@ declare global {
              * See [here](https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#9-launch-with-a-specific-language-ios-only) for more information.
              *
              * @param column number of datepicker column (starts from 0)
-             * @param value string value in setted column (must be correct)
+             * @param value string value in set column (must be correct)
              * @example
              * await expect(element(by.type('UIPickerView'))).toBeVisible();
              * await element(by.type('UIPickerView')).setColumnToValue(1,"6");
diff --git a/detox/src/devices/drivers/android/AndroidDriver.js b/detox/src/devices/drivers/android/AndroidDriver.js
index a768a2ba5..80a6bf558 100644
--- a/detox/src/devices/drivers/android/AndroidDriver.js
+++ b/detox/src/devices/drivers/android/AndroidDriver.js
@@ -1,6 +1,6 @@
 const _ = require('lodash');
 const path = require('path');
-const fs = require('fs');
+const fs = require('fs-extra');
 const URL = require('url').URL;
 const DeviceDriverBase = require('../DeviceDriverBase');
 const logger = require('../../../utils/logger');


Test patch:
diff --git a/detox/src/devices/drivers/android/AndroidDriver.test.js b/detox/src/devices/drivers/android/AndroidDriver.test.js
index 38495bb53..ac562aaf6 100644
--- a/detox/src/devices/drivers/android/AndroidDriver.test.js
+++ b/detox/src/devices/drivers/android/AndroidDriver.test.js
@@ -467,11 +467,11 @@ describe('Android driver', () => {
   });
 
   const setUpModuleDepMocks = () => {
-    jest.mock('fs', () => ({
+    jest.mock('fs-extra', () => ({
       existsSync: jest.fn(),
       realpathSync: jest.fn(),
     }));
-    fs = require('fs');
+    fs = require('fs-extra');
 
     jest.mock('../../../utils/encoding', () => ({
       encodeBase64: (x) => `base64(${x})`,