-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a5a657
commit 2eabf21
Showing
11 changed files
with
373 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
android/app/src/androidTest/java/com/reactnativeci/DetoxTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.reactnativeci; // Detox: replace with the actual package name | ||
|
||
import android.support.test.filters.LargeTest; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import com.wix.detox.Detox; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class DetoxTest { | ||
|
||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); | ||
|
||
@Test | ||
public void runDetoxTests() throws InterruptedException { | ||
Detox.runTests(mActivityRule); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe("App is functional", () => { | ||
beforeEach(async () => { | ||
await device.reloadReactNative(); // reload the app before running each of the tests | ||
}); | ||
|
||
it("should show loader", async () => { | ||
await expect(element(by.id("loader"))).toExist(); // we're using toExist() instead of isVisible() because the ActivityIndicator component becomes invisible when a testID prop is passed in | ||
}); | ||
|
||
it("should load cards", async () => { | ||
// assumes that if one card exists, then all the other cards also exists | ||
await expect(element(by.id("card-Blaziken"))).toExist(); | ||
}); | ||
|
||
it("card changes state when it is clicked", async () => { | ||
await element(by.id("card-Entei")).tap(); // not favorited by default | ||
await expect(element(by.id("card-Entei-heart"))).toExist(); // should be marked as favorite | ||
await element(by.id("card-Entei")).tap(); // clicking for a second time un-favorites it | ||
await expect(element(by.id("card-Entei-heart-o"))).toExist(); // should not be marked as favorite | ||
}); | ||
|
||
it("card state is kept in local storage", async () => { | ||
await element(by.id("card-Entei")).tap(); // not favorited by default | ||
await device.reloadReactNative(); // has the same effect of re-launching the app | ||
await expect(element(by.id("card-Entei-heart"))).toExist(); // should still be favorited after app is reloaded | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const detox = require('detox'); | ||
const config = require('../package.json').detox; | ||
const adapter = require('detox/runners/mocha/adapter'); | ||
|
||
before(async () => { | ||
await detox.init(config); | ||
}); | ||
|
||
beforeEach(async function () { | ||
await adapter.beforeEach(this); | ||
}); | ||
|
||
afterEach(async function () { | ||
await adapter.afterEach(this); | ||
}); | ||
|
||
after(async () => { | ||
await detox.cleanup(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--recursive --timeout 120000 --bail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.