Skip to content

Commit

Permalink
Feature: add automated end-to-end testing using detox (#230)
Browse files Browse the repository at this point in the history
* add detox to project

* configure env

* add README.md

* fix test

* add eslint-plugin-detox

* switch to release

* fix Ðbinary path to test release version

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
  • Loading branch information
arufanov and muhsin-k committed Sep 11, 2020
1 parent 7cac142 commit 1f5feca
Show file tree
Hide file tree
Showing 10 changed files with 1,039 additions and 22 deletions.
21 changes: 21 additions & 0 deletions .detoxrc.json
@@ -0,0 +1,21 @@
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"configurations": {
"ios": {
"type": "ios.simulator",
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/Chatwoot.app",
"build": "xcodebuild -workspace ios/Chatwoot.xcworkspace -scheme Chatwoot -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"device": {
"type": "iPhone 11"
}
},
"android": {
"type": "android.emulator",
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY",
"device": {
"avdName": "Pixel_2_API_29"
}
}
}
}
1 change: 1 addition & 0 deletions .eslintrc.js
@@ -1,6 +1,7 @@
module.exports = {
root: true,
extends: '@react-native-community',
plugins: ['detox'],
rules: {
'no-console': 2,
'react/prop-types': 2,
Expand Down
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -39,6 +39,15 @@
<img src=".github/settings.png" alt="settings"width="250">
</p>

## Configure and run tests

- Add a new brew formula: brew tap wix/brew
- Install simulators: brew install wix/applesimutils
- Build application: detox build --configuration ios
- Run tests: detox test --configuration ios --loglevel trace
- Manage simulators: /usr/bin/xcrun simctl list


## Download Android/iOS application

To help with testing Chatwoot updates before they're released, you can install the Android/iOS beta version.
Expand Down
8 changes: 8 additions & 0 deletions e2e/config.json
@@ -0,0 +1,8 @@
{
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 120000,
"testRegex": "\\.e2e\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
23 changes: 23 additions & 0 deletions e2e/environment.js
@@ -0,0 +1,23 @@
const {
DetoxCircusEnvironment,
SpecReporter,
WorkerAssignReporter,
} = require('detox/runners/jest-circus');

class CustomDetoxEnvironment extends DetoxCircusEnvironment {
constructor(config) {
super(config);

// Can be safely removed, if you are content with the default value (=300000ms)
this.initTimeout = 300000;

// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
// This is strictly optional.
this.registerListeners({
SpecReporter,
WorkerAssignReporter,
});
}
}

module.exports = CustomDetoxEnvironment;
11 changes: 11 additions & 0 deletions e2e/welcome.e2e.js
@@ -0,0 +1,11 @@
/* eslint-env detox/detox, jest */

describe('Example', () => {
beforeEach(async () => {
await device.reloadReactNative();
});

it('should have welcome screen', async () => {
await expect(element(by.text('Connect'))).toBeVisible();
});
});
1 change: 0 additions & 1 deletion ios/Chatwoot.xcodeproj/project.pbxproj
Expand Up @@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
00E356F31AD99517003FC87E /* ChatwootTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* ChatwootTests.m */; };
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Expand Up @@ -651,4 +651,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 359eeed31941826235cdc4a3c6b998cb2e176764

COCOAPODS: 1.8.4
COCOAPODS: 1.9.3
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -66,10 +66,13 @@
"@bam.tech/react-native-make": "^3.0.0",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"detox": "^17.4.6",
"eslint": "^6.5.1",
"eslint-plugin-detox": "^1.0.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"jest": "^25.1.0",
"jest-circus": "^26.4.2",
"lint-staged": "^10.2.13",
"metro-react-native-babel-preset": "^0.59.0",
"prettier": "^2.1.1",
Expand Down

0 comments on commit 1f5feca

Please sign in to comment.