Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.

Commit be9f281

Browse files
committed
test(): split screenshots per device
1 parent 7a7b0fd commit be9f281

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

detox/detox.config.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
exports.ANDROID_SDK_VERSION = 31;
2-
exports.IOS_SDK_VERSION = 15;
1+
const ANDROID_SDK_VERSION = 31;
2+
const ANDROID_DEVICE_TYPE = "pixel";
3+
const IOS_SDK_VERSION = 15;
4+
const IOS_DEVICE_TYPE = "iPhone 13 Pro Max";
35

4-
exports = {
6+
module.exports = {
7+
ANDROID_SDK_VERSION,
8+
ANDROID_DEVICE_TYPE,
9+
IOS_SDK_VERSION,
10+
IOS_DEVICE_TYPE,
511
"test-runner": "npx jest",
612
"runner-config": `${__dirname}/jest.detox.config.js`,
713
apps: {
@@ -19,14 +25,14 @@ exports = {
1925
ios: {
2026
type: "ios.simulator",
2127
device: {
22-
type: "iPhone 13 Pro Max",
23-
os: `iOS ${this.IOS_SDK_VERSION}`
28+
type: IOS_DEVICE_TYPE,
29+
os: `iOS ${IOS_SDK_VERSION}`
2430
}
2531
},
2632
android: {
2733
type: "android.emulator",
2834
device: {
29-
avdName: `EMULATOR_NATIVE_${this.ANDROID_SDK_VERSION}`
35+
avdName: `NATIVE_${ANDROID_DEVICE_TYPE}_${ANDROID_SDK_VERSION}`
3036
}
3137
}
3238
},

detox/jest.detox.startup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ expect.extend({
1313
toMatchImageSnapshot(screenshot, options = {}) {
1414
const { currentTestName } = this;
1515
const platform = device.getPlatform();
16-
const customSnapshotsDir = join(resolve("./"), "image-snapshots", platform);
17-
const customDiffDir = join(resolve("./"), "image-snapshots/results", platform);
16+
const customSnapshotsDir = join(resolve("./"), "image-snapshots", platform, device.name);
17+
const customDiffDir = join(resolve("./"), "image-snapshots/results", platform, device.name);
1818

1919
return toMatchImageSnapshot.call(this, screenshot, {
2020
customDiffConfig: { threshold: 0.15 },

detox/scripts/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function downloadFile(url) {
2626

2727
function execCommand(command, ignoreErrorContaining) {
2828
try {
29-
execSync(command, { stdio: "ignore" });
29+
execSync(command);
3030
} catch (error) {
3131
if (!error.message.includes(ignoreErrorContaining)) {
3232
throw new Error(error);

detox/scripts/setup-android.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { ANDROID_SDK_VERSION } = require("../detox.config");
1+
const { ANDROID_SDK_VERSION, ANDROID_DEVICE_TYPE } = require("../detox.config");
22
const { downloadFile, execCommand } = require("./helpers");
33

44
main().catch(e => {
@@ -19,7 +19,7 @@ async function main() {
1919

2020
console.log("Creating Android emulator...");
2121
execCommand(
22-
`avdmanager -s create avd -n EMULATOR_NATIVE_${ANDROID_SDK_VERSION} -k 'system-images;android-${ANDROID_SDK_VERSION};google_apis;x86_64' -f -d 'pixel' -c 1000M`
22+
`avdmanager -s create avd -n NATIVE_${ANDROID_DEVICE_TYPE}_${ANDROID_SDK_VERSION} -k 'system-images;android-${ANDROID_SDK_VERSION};google_apis;x86_64' -f -d '${ANDROID_DEVICE_TYPE}' -c 1000M`
2323
);
2424

2525
console.log("Done!");

0 commit comments

Comments
 (0)