forked from paufau/react-native-multiple-modals-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e-matrix.js
More file actions
130 lines (121 loc) · 3.38 KB
/
e2e-matrix.js
File metadata and controls
130 lines (121 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { execSync } from 'child_process';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const { updateScreenshots, steps, platform } = yargs(hideBin(process.argv))
.option('update-screenshots', {
alias: 'u',
describe: 'Update the expected screenshots with the current ones',
type: 'boolean',
default: false
})
.option('steps', {
alias: 's',
describe: 'Run specific steps in the E2E process',
type: 'array',
choices: ['setup', 'tests'],
default: ['setup', 'tests']
})
.option('platform', {
alias: 'p',
describe: 'Specify the platform to run tests on',
type: 'string',
choices: ['android', 'ios'],
})
.help()
.alias('help', 'h')
.parse();
// TODO better device mapping
const testCases = [
// New arch
// RN 80
{
project: 'rn80',
device: 'Pixel_9_Pro',
platform: 'android',
architecture: 'new'
},
{
project: 'rn80',
device: '313E0F09-0488-40BE-B902-E29B09229A22',
platform: 'ios',
architecture: 'new'
},
// RN 78
{
project: 'rn78',
device: 'Pixel_9_Pro',
platform: 'android',
architecture: 'new'
},
{
project: 'rn78',
device: '313E0F09-0488-40BE-B902-E29B09229A22',
platform: 'ios',
architecture: 'new'
},
// Old arch
// RN 80
{
project: 'rn80',
device: '313E0F09-0488-40BE-B902-E29B09229A22',
platform: 'ios',
architecture: 'old'
},
{
project: 'rn80',
device: 'Pixel_9_Pro',
platform: 'android',
architecture: 'old'
},
// RN 78
{
project: 'rn78',
device: '313E0F09-0488-40BE-B902-E29B09229A22',
platform: 'ios',
architecture: 'old'
},
{
project: 'rn78',
device: 'Pixel_9_Pro',
platform: 'android',
architecture: 'old'
}
]
const stopMetroServer = () => {
try {
// Check if Metro server is running
execSync('pgrep -f "cli.js start"', { stdio: 'ignore' });
// If we reach here, Metro is running, so stop it
execSync('pkill -f "cli.js start"', { stdio: 'ignore' });
console.log('Metro server stopped successfully.');
} catch (error) {
// If pgrep fails, Metro is not running
if (error.status === 1) {
console.log('Metro server is not running.');
} else {
console.error('Failed to stop Metro server:', error.message);
}
}
};
const cases = testCases.filter(testCase => {
if (platform) {
return testCase.platform === platform;
}
return true;
});
cases.forEach(({ project, device, platform, architecture }) => {
console.log(`Running tests for project: ${project}, device: ${device}, platform: ${platform}, architecture: ${architecture}`);
stopMetroServer();
if (steps.includes('setup')) {
console.log('Setting up project...');
execSync(`yarn project:run --platform=${platform} --project=${project} --device=${device} --arch=${architecture}`, { stdio: 'inherit' });
} else {
console.log('Skipping project setup.');
// Spawn Metro server in a separate terminal
execSync(`osascript -e 'tell application "Terminal" to do script "cd ${process.cwd()} && cd ${project} && yarn start"'`);
}
if (steps.includes('tests')) {
console.log(`Running E2E tests for project: ${project} on device: ${device}`);
execSync(`yarn e2e:run --architecture=${architecture} --device=${device} --project=${project} --platform=${platform} --update-screenshots=${updateScreenshots}`, { stdio: 'inherit' });
}
});