Repository: wix/Detox
Pull request #3947 (2023-02-21 20:56:03)

docs: typo lable to label
## Description

<!--
Thank you for contributing!

Step 1: Before submitting a pull request that introduces a new functionality or fixes a bug,
please open an issue where we could discuss the suggestion, problem - and potential ways to fix.
-->

- This pull request addresses the issue described here: #<?>

<!--
Step 2: Provide an overview of how your fix / enhancement works.
If possible, provide screenshots of the before and after states (even for simple command line options - show the terminal).
-->

In this pull request, I have …

<!--
Step 3: Please review the checklist below.
-->

---


> _For features/enhancements:_
 - [x] I have added/updated the relevant references in the [documentation](https://github.com/wix/Detox/tree/master/docs) files.

> _For API changes:_
 - [x] I have made the necessary changes in the [types index](https://github.com/wix/Detox/blob/master/detox/index.d.ts) file.



Patch:
diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT_ANDROID.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT_ANDROID.yml
index 6380e1ea6..4af7990be 100644
--- a/.github/ISSUE_TEMPLATE/BUG_REPORT_ANDROID.yml
+++ b/.github/ISSUE_TEMPLATE/BUG_REPORT_ANDROID.yml
@@ -54,14 +54,14 @@ body:
     id: detox-logs
     attributes:
       label: Detox logs
-      description: Please run your tests using the `--loglevel trace` argument. See [artifacts documentation](https://wix.github.io/Detox/docs/api/artifacts).
+      description: Please run your tests using the `--loglevel trace` argument. See [artifacts documentation](https://wix.github.io/Detox/docs/config/artifacts).
       value: "<details><summary>Detox logs</summary>\n\n```\npaste logs here!\n```\n\n</details>"
   - type: textarea
     id: device-logs
     attributes:
       label: Device logs
-      description: Please run your tests using the `--record-logs all` argument. See [artifacts documentation](https://wix.github.io/Detox/docs/api/artifacts).
-      value: "<details><summary>Device logs</summary>\n\n```\npaste logs here!\n```\n\n</details>"
+      description: Please run your tests using the `--record-logs all` argument and paste the `device.log` file. See [artifacts documentation](https://wix.github.io/Detox/docs/config/artifacts#launch-arguments).
+      value: "<details><summary>Device logs</summary>\n\n```\npaste your device.log here!\n```\n\n</details>"
   - type: textarea
     id: test-artifacts
     attributes:
diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT_IOS.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT_IOS.yml
index 9f6c29116..9e609a3ac 100644
--- a/.github/ISSUE_TEMPLATE/BUG_REPORT_IOS.yml
+++ b/.github/ISSUE_TEMPLATE/BUG_REPORT_IOS.yml
@@ -62,8 +62,8 @@ body:
     id: device-logs
     attributes:
       label: Device logs
-      description: Please run your tests using the `--record-logs all` argument. See [artifacts documentation](https://wix.github.io/Detox/docs/api/artifacts).
-      value: "<details><summary>Device logs</summary>\n\n```\npaste logs here!\n```\n\n</details>"
+      description: Please run your tests using the `--record-logs all` argument and paste the `device.log` file. See [artifacts documentation](https://wix.github.io/Detox/docs/config/artifacts#launch-arguments).
+      value: "<details><summary>Device logs</summary>\n\n```\npaste your device.log here!\n```\n\n</details>"
   - type: textarea
     id: test-artifacts
     attributes:
diff --git a/detox/package.json b/detox/package.json
index 7d1de186f..a6ae4e42e 100644
--- a/detox/package.json
+++ b/detox/package.json
@@ -1,7 +1,7 @@
 {
   "name": "detox",
   "description": "E2E tests and automation for mobile",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "bin": {
     "detox": "local-cli/cli.js"
   },
diff --git a/detox/runners/jest/index.d.ts b/detox/runners/jest/index.d.ts
index dd0ec5777..98187712b 100644
--- a/detox/runners/jest/index.d.ts
+++ b/detox/runners/jest/index.d.ts
@@ -48,9 +48,10 @@ declare module 'detox/runners/jest' {
   }
 
   export class DetoxCircusEnvironment extends NodeEnvironment {
-    public readonly handleTestEvent: (event: unknown, state: unknown) => void | Promise<void>;
     public readonly testPath: string;
 
+    public handleTestEvent(event: unknown, state: unknown): void | Promise<void>;
+
     protected registerListeners(map: Record<string, DetoxListenerFactory>): void;
     protected setupTimeout: number;
     protected teardownTimeout: number;
diff --git a/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js b/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js
index 07eb7ce9f..3948f7716 100644
--- a/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js
+++ b/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js
@@ -28,7 +28,7 @@ class GenyCloudExec {
   }
 
   startInstance(recipeUUID, instanceName) {
-    return this._exec(`instances start --stop-when-inactive --no-wait ${recipeUUID} "${instanceName}"`, { retries: 0 });
+    return this._exec(`instances start --no-wait ${recipeUUID} "${instanceName}"`, { retries: 0 });
   }
 
   adbConnect(instanceUUID) {
diff --git a/examples/demo-native-android/package.json b/examples/demo-native-android/package.json
index ce55a7701..307eee93a 100644
--- a/examples/demo-native-android/package.json
+++ b/examples/demo-native-android/package.json
@@ -1,13 +1,13 @@
 {
   "name": "detox-demo-native-android",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "private": true,
   "scripts": {
     "packager": "react-native start",
     "detox-server": "detox run-server"
   },
   "devDependencies": {
-    "detox": "^20.1.5"
+    "detox": "^20.2.1"
   },
   "detox": {}
 }
diff --git a/examples/demo-native-ios/package.json b/examples/demo-native-ios/package.json
index 1c00b8ca2..6c3ab6604 100644
--- a/examples/demo-native-ios/package.json
+++ b/examples/demo-native-ios/package.json
@@ -1,9 +1,9 @@
 {
   "name": "detox-demo-native-ios",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "private": true,
   "devDependencies": {
-    "detox": "^20.1.5"
+    "detox": "^20.2.1"
   },
   "detox": {
     "specs": "",
diff --git a/examples/demo-plugin/package.json b/examples/demo-plugin/package.json
index 4e4d32ceb..d2146b300 100644
--- a/examples/demo-plugin/package.json
+++ b/examples/demo-plugin/package.json
@@ -1,12 +1,12 @@
 {
   "name": "demo-plugin",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "private": true,
   "scripts": {
     "test:plugin": "detox test --configuration plugin -l verbose"
   },
   "devDependencies": {
-    "detox": "^20.1.5",
+    "detox": "^20.2.1",
     "jest": "^28.0.0"
   },
   "detox": {
diff --git a/examples/demo-react-native-detox-instruments/package.json b/examples/demo-react-native-detox-instruments/package.json
index e609225c1..2cd8e92ee 100644
--- a/examples/demo-react-native-detox-instruments/package.json
+++ b/examples/demo-react-native-detox-instruments/package.json
@@ -1,10 +1,10 @@
 {
   "name": "demo-react-native-detox-instruments",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "private": true,
   "scripts": {},
   "devDependencies": {
-    "detox": "^20.1.5"
+    "detox": "^20.2.1"
   },
   "detox": {
     "configurations": {
diff --git a/examples/demo-react-native/package.json b/examples/demo-react-native/package.json
index 4206f2f26..e77079a8e 100644
--- a/examples/demo-react-native/package.json
+++ b/examples/demo-react-native/package.json
@@ -1,6 +1,6 @@
 {
   "name": "example",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "private": true,
   "scripts": {
     "start": "react-native start",
@@ -30,7 +30,7 @@
   "devDependencies": {
     "@types/fs-extra": "^9.0.13",
     "@types/jest": "^29.2.1",
-    "detox": "^20.1.5",
+    "detox": "^20.2.1",
     "fs-extra": "^9.1.0",
     "jest": "^29.2.1",
     "ts-jest": "^29.0.3",
diff --git a/lerna.json b/lerna.json
index eedbd16d3..4f3abc88e 100644
--- a/lerna.json
+++ b/lerna.json
@@ -13,7 +13,7 @@
     "generation",
     "."
   ],
-  "version": "20.1.5",
+  "version": "20.2.1",
   "npmClient": "npm",
   "command": {
     "publish": {
diff --git a/package.json b/package.json
index 67b49e48a..60825dd14 100644
--- a/package.json
+++ b/package.json
@@ -54,5 +54,5 @@
     "shell-utils": "1.x.x",
     "unified": "^10.1.0"
   },
-  "version": "20.1.5"
+  "version": "20.2.1"
 }
diff --git a/website/versioned_docs/version-20.x/guide/cucumber-js-integration.md b/website/versioned_docs/version-20.x/guide/cucumber-js-integration.md
new file mode 100644
index 000000000..03a9e382f
--- /dev/null
+++ b/website/versioned_docs/version-20.x/guide/cucumber-js-integration.md
@@ -0,0 +1,93 @@
+# Cucumber.js Integration
+
+:::note Community resource
+
+This is an article generously contributed [by the community][initial PR].
+Feel free to [contribute to it][Contributing] by submitting a pull request
+if you find any errors or have suggestions for improvements.
+If you have any questions, please get in touch with the author directly.
+
+:::
+
+[Cucumber] is a tool for running automated tests written in plain language.
+It can be integrated with Detox to run end-to-end tests for mobile applications
+if you manage [Detox Internals API] from [Cucumber.js hooks].
+
+In your `init.js` or `init.ts` file, please import `detox/internals` on top of the file:
+
+```js
+import detox from 'detox/internals'
+```
+
+Also import the hooks we'll be using just a bit later:
+
+```js
+import { Before, BeforeAll, AfterAll, After,  ITestCaseHookParameter } from '@cucumber/cucumber'
+```
+
+Define the earliest [Cucumber.js] hook, `BeforeAll`, where you’ll [initialize][`detox.init()`] Detox and launch the app:
+
+```js
+BeforeAll({ timeout: 120 * 1000 }, async () => {
+    await detox.init()
+    await device.launchApp()
+})
+```
+
+You must also tell Detox explicitly when [Cucumber.js] starts a test via calling [`detox.onTestStart()`] inside `Before` hook.
+Otherwise, Detox won't be able to _start recording_ logs, screenshots, videos, and other artifacts:
+
+```js
+Before(async (message: ITestCaseHookParameter) => {
+    const { pickle } = message
+    await detox.onTestStart({
+        title: pickle.uri,
+        fullName: pickle.name,
+        status: 'running',
+    })
+})
+```
+
+The symmetrical step is to inform Detox that the current test is over via calling [`detox.onTestDone()`] inside `After` hook.
+Otherwise, Detox won't be able to _save_ logs, screenshots, videos, and other artifacts:
+
+```js
+After(async (message: ITestCaseHookParameter) => {
+    const { pickle, result } = message
+    await detox.onTestDone({
+        title: pickle.uri,
+        fullName: pickle.name,
+        status: result ? 'passed' : 'failed',
+    })
+})
+```
+
+After the tests are over, you should call [`detox.cleanup()`] inside `AfterAll` hook so that Detox can clean up all the resources it has allocated:
+
+```js
+AfterAll(async () => {
+    await detox.cleanup();
+})
+```
+
+For more information on [Cucumber.js] please check out this [documentation][Cucumber.js].
+
+[Cucumber]: https://cucumber.io/
+
+[Cucumber.js]: https://github.com/cucumber/cucumber-js#documentation
+
+[Cucumber.js hooks]: https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/hooks.md
+
+[Initial PR]: https://github.com/wix/Detox/pull/3858
+
+[Detox Internals API]: ../api/internals.mdx
+
+[`detox.init()`]: ../api/internals.mdx#initoptions-promise
+
+[`detox.cleanup()`]: ../api/internals.mdx#cleanup-promise
+
+[`detox.onTestStart()`]: ../api/internals.mdx#onteststartevent-promise
+
+[`detox.onTestDone()`]: ../api/internals.mdx#ontestdoneevent-promise
+
+[Contributing]: ../contributing.md
diff --git a/website/versioned_sidebars/version-20.x-sidebars.json b/website/versioned_sidebars/version-20.x-sidebars.json
index 6b958bd21..98e9990fa 100644
--- a/website/versioned_sidebars/version-20.x-sidebars.json
+++ b/website/versioned_sidebars/version-20.x-sidebars.json
@@ -28,6 +28,7 @@
         "guide/developing-while-writing-tests",
         "guide/android-dev-env",
         "guide/proguard-configuration",
+        "guide/cucumber-js-integration",
         "guide/uninstalling"
       ]
     },


Test patch:
diff --git a/detox/runners/jest/testEnvironment/index.js b/detox/runners/jest/testEnvironment/index.js
index 9b6c4d997..5dbcc2d9e 100644
--- a/detox/runners/jest/testEnvironment/index.js
+++ b/detox/runners/jest/testEnvironment/index.js
@@ -51,6 +51,7 @@ class DetoxCircusEnvironment extends NodeEnvironment {
 
     log.trace.begin(this.testPath);
 
+    this.handleTestEvent = this.handleTestEvent.bind(this);
     this.setup = this._wrapSetup(this.setup);
     this.teardown = this._wrapTeardown(this.teardown);
 
@@ -69,7 +70,7 @@ class DetoxCircusEnvironment extends NodeEnvironment {
     await this.initDetox();
   }
 
-  handleTestEvent = async (event, state) => {
+  async handleTestEvent(event, state) {
     this._timer.schedule(state.testTimeout != null ? state.testTimeout : this.setupTimeout);
 
     if (SYNC_CIRCUS_EVENTS.has(event.name)) {
@@ -77,7 +78,7 @@ class DetoxCircusEnvironment extends NodeEnvironment {
     } else {
       await this._handleTestEventAsync(event, state);
     }
-  };
+  }
 
   /** @override */
   async teardown() {
diff --git a/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.test.js b/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.test.js
index 02ca38a6c..28d3689ff 100644
--- a/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.test.js
+++ b/detox/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.test.js
@@ -69,7 +69,7 @@ describe('Genymotion-cloud executable', () => {
     {
       commandName: 'Start Instance',
       commandExecFn: () => uut.startInstance(recipeUUID, instanceName),
-      expectedExec: `"mock/path/to/gmsaas" --format compactjson instances start --stop-when-inactive --no-wait ${recipeUUID} "${instanceName}"`,
+      expectedExec: `"mock/path/to/gmsaas" --format compactjson instances start --no-wait ${recipeUUID} "${instanceName}"`,
       expectedExecOptions: { retries: 0 },
     },
     {
diff --git a/detox/test/package.json b/detox/test/package.json
index 4b48c5abd..4c9589af0 100644
--- a/detox/test/package.json
+++ b/detox/test/package.json
@@ -1,6 +1,6 @@
 {
   "name": "detox-test",
-  "version": "20.1.5",
+  "version": "20.2.1",
   "private": true,
   "engines": {
     "node": ">=14.5.0"
@@ -55,7 +55,7 @@
     "@typescript-eslint/eslint-plugin": "^5.4.0",
     "@typescript-eslint/parser": "^5.4.0",
     "cross-env": "^7.0.3",
-    "detox": "^20.1.5",
+    "detox": "^20.2.1",
     "eslint": "^7.32.0",
     "eslint-plugin-unicorn": "^39.0.0",
     "execa": "^5.1.1",
diff --git a/detox/test/types/detox-integration-tests.ts b/detox/test/types/detox-integration-tests.ts
index d031129db..704664d76 100644
--- a/detox/test/types/detox-integration-tests.ts
+++ b/detox/test/types/detox-integration-tests.ts
@@ -141,6 +141,14 @@ class CustomEnvironment extends DetoxCircusEnvironment {
       OmniListener,
     });
   }
+
+  handleTestEvent(event: Circus.Event, state: Circus.State): void | Promise<void> {
+    if (event.name === 'test_done') {
+      console.log(event.test.name);
+    }
+
+    return super.handleTestEvent(event, state);
+  }
 }
 
 async function main() {
diff --git a/docs/guide/test-id.mdx b/docs/guide/test-id.mdx
index 5ae5c68e2..6a26deba7 100644
--- a/docs/guide/test-id.mdx
+++ b/docs/guide/test-id.mdx
@@ -87,7 +87,7 @@ const ITEMS = [
 function YourScreen() {
   const renderItem = ({ item }) => (
 // highlight-next-line
-    <YourCustomComponent testID={'listItem'} lable={item.title} />
+    <YourCustomComponent testID={'listItem'} label={item.title} />
   );
 
   return (
@@ -110,7 +110,7 @@ Instead, you could generate a unique `testID` for every list item with the `inde
 
 ```jsx
   const renderItem = ({ item, index }) => (
-    <YourCustomComponent testID={`listItem.${index + 1}`} lable={item.title} />
+    <YourCustomComponent testID={`listItem.${index + 1}`} label={item.title} />
   );
 ```