detox 20.13.0 → 20.13.1-smoke.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0-javadoc.jar → 20.13.1-smoke.0/detox-20.13.1-smoke.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0.pom.sha512 → 20.13.1-smoke.0/detox-20.13.1-smoke.0-javadoc.jar.sha256} +1 -1
  5. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0-sources.jar → 20.13.1-smoke.0/detox-20.13.1-smoke.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0.pom → 20.13.1-smoke.0/detox-20.13.1-smoke.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.13.1-smoke.0/detox-20.13.1-smoke.0.pom.sha512 +1 -0
  21. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  22. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  26. package/Detox-ios-src.tbz +0 -0
  27. package/Detox-ios.tbz +0 -0
  28. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/MotionEvents.kt +29 -2
  29. package/jest.config.js +108 -0
  30. package/package.json +3 -99
  31. package/runners/jest/reporter.js +21 -1
  32. package/runners/jest/reporters/DetoxIPCReporter.js +34 -0
  33. package/runners/jest/reporters/DetoxReporterDispatcher.js +144 -0
  34. package/runners/jest/reporters/DetoxSummaryReporter.js +16 -0
  35. package/runners/jest/reporters/DetoxVerboseReporter.js +16 -0
  36. package/runners/jest/reporters/index.js +6 -0
  37. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +3 -5
  38. package/src/devices/allocation/factories/ios.js +1 -4
  39. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +5 -4
  40. package/src/devices/runtime/factories/ios.js +0 -2
  41. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.md5 +0 -1
  42. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha1 +0 -1
  43. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha256 +0 -1
  44. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha512 +0 -1
  45. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.md5 +0 -1
  46. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha1 +0 -1
  47. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha256 +0 -1
  48. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha512 +0 -1
  49. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar +0 -0
  50. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.md5 +0 -1
  51. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha1 +0 -1
  52. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha256 +0 -1
  53. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha512 +0 -1
  54. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.md5 +0 -1
  55. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha1 +0 -1
  56. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha256 +0 -1
  57. package/runners/jest/reporters/DetoxReporter.js +0 -154
  58. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +0 -25
@@ -0,0 +1 @@
1
+ f11641164a4f2ccb3b0b9de91e399646
@@ -0,0 +1 @@
1
+ 97c103ba6e127dbe2dc1b47a972aa3ae9a4e1d65
@@ -1 +1 @@
1
- 216ecb00454a1e03ef9ab2a197b616c4d326ec6ef47fd08b83b22d57c2c9d4dc37725a3c4d19600874074b40918387cebd1be11d558270af4ab7e797af40607f
1
+ 00f9de5a01b9153372c3675054b3cfbcdafa40c5ce88ba851ef71e17d0b61454
@@ -0,0 +1 @@
1
+ c88f0877227029128911cdb592c899db3431279e3338ab0b28aef8a6dff658384d628aebf05b08538adb3127ca3d897cc7241101e722965560100015b3cb0bba
@@ -0,0 +1 @@
1
+ 1b4b53835ca72328129cda1007497a31
@@ -0,0 +1 @@
1
+ 3e27db4c54c0ce44edfef999eef17d8d326f2a70
@@ -0,0 +1 @@
1
+ 11b9a7566d6654e66fbfb76a92da02bfbab8c97463199839590d2c0ea2307dc4
@@ -0,0 +1 @@
1
+ ba73a0da52b6d571c6aa370df12e4f65db8424dcdb2450f83825d9abf0faf3f54211eec8d392dc689a191e09aff1396312a551b280d17710d7bb4cc8d2e2e356
@@ -0,0 +1 @@
1
+ 02670d8571dd840d7c1e604d43356b33
@@ -0,0 +1 @@
1
+ 4580dad60e33036c50d19b34a9fe021be5304ac8
@@ -0,0 +1 @@
1
+ d843d03b68588878b7afdcd99421527b3a60145afb450f01e7aea0263c9232ea
@@ -0,0 +1 @@
1
+ f6ac58b1b02c9fe567cb29c2ecdf28f8ef7fb092438eafcbdcb7f2ba5a64f7a4a725d1d6a021421b19ea78f619feead3051ff129164a25e0e031985f1e635539
@@ -3,7 +3,7 @@
3
3
  <modelVersion>4.0.0</modelVersion>
4
4
  <groupId>com.wix</groupId>
5
5
  <artifactId>detox</artifactId>
6
- <version>20.13.0</version>
6
+ <version>20.13.1-smoke.0</version>
7
7
  <packaging>aar</packaging>
8
8
  <name>Detox</name>
9
9
  <description>Gray box end-to-end testing and automation library for mobile apps</description>
@@ -0,0 +1 @@
1
+ bfae4a3d65c10d4f5e1720d34350c38c
@@ -0,0 +1 @@
1
+ c963c4f616a8a6a534567a173f313b49937ae402
@@ -0,0 +1 @@
1
+ d12f147001264686f12bc4b1b3af172aa4c55a704f12cb31e328ad4f0fd5d8f5
@@ -0,0 +1 @@
1
+ 917b7c2836e3f46c1bc94c01bdd819b740e4d45e197aac6cf80cbaf9e84f3e582d3c43cfdb31d68ce1cf2673b900b5f9b7c52ec94e005eb6ac113050e54399f6
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.13.0</latest>
7
- <release>20.13.0</release>
6
+ <latest>20.13.1-smoke.0</latest>
7
+ <release>20.13.1-smoke.0</release>
8
8
  <versions>
9
- <version>20.13.0</version>
9
+ <version>20.13.1-smoke.0</version>
10
10
  </versions>
11
- <lastUpdated>20231002075250</lastUpdated>
11
+ <lastUpdated>20231013072538</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 253d464cc30a2d00e586eadca31d5952
1
+ d2a9c4ea918b24f4cf98e1194d3fafd2
@@ -1 +1 @@
1
- 1a402a8246b4532c9be982b61c2b4d3b3e6ab741
1
+ 90e450b35693d5015c5ac0dc212700fbe1780c10
@@ -1 +1 @@
1
- 09104c2799b83cedb2f68628779529f7efb1e96b3e33c0ed8c814da6a5e19ef8
1
+ ee38fbc385e4c227685a4fc0290cda3a77f6056cc27e914db9b055c9ac14c66d
@@ -1 +1 @@
1
- b1547a601cae891dc3f1a58b66c63e70670d9f3e512c50cb6d26d40568972b94cb2f28887c13ea8d04e2b75b57bba73f8ba4ad780b471009fed3cd4e42b469ae
1
+ 4fca6bd96454869278ee77d1e116e4f929a898943b979896ff04a7e618e52a5122278890227543e2b00e3968f997eec0a3cd6b7a91fe64b0a4f1e0ba36c0ffdb
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
@@ -46,8 +46,35 @@ class MotionEvents {
46
46
  0)
47
47
  }
48
48
 
49
- fun obtainUpEvent(downEvent: MotionEvent, eventTime: Long, x: Float, y: Float): MotionEvent
50
- = MotionEvent.obtain(downEvent.downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0)!!
49
+ fun obtainUpEvent(downEvent: MotionEvent, eventTime: Long, x: Float, y: Float): MotionEvent {
50
+ val pointerProperties = MotionEvent.PointerProperties().apply {
51
+ id = 0
52
+ toolType = MotionEvent.TOOL_TYPE_UNKNOWN
53
+ }
54
+ val pointerCoords = MotionEvent.PointerCoords().apply {
55
+ clear()
56
+ this.x = x
57
+ this.y = y
58
+ this.pressure = 0f
59
+ this.size = 1f
60
+ }
61
+ return MotionEvent.obtain(
62
+ downEvent.downTime,
63
+ eventTime,
64
+ MotionEvent.ACTION_UP,
65
+ 1, // pointerCounts
66
+ arrayOf(pointerProperties),
67
+ arrayOf(pointerCoords),
68
+ 0, // metaState
69
+ downEvent.buttonState,
70
+ downEvent.xPrecision,
71
+ downEvent.yPrecision,
72
+ 0, // deviceId
73
+ 0, // edgeFlags
74
+ downEvent.source,
75
+ 0
76
+ )
77
+ }
51
78
 
52
79
  fun sendDownAsync(uiController: UiController, x: Float, y: Float, precision: FloatArray = PRECISION): MotionEvent {
53
80
  val downEvent = obtainDownEvent(x, y, precision, null)
package/jest.config.js ADDED
@@ -0,0 +1,108 @@
1
+ const DEBUG = process.argv.includes('--reporters');
2
+
3
+ /** @type{import('jest-allure2-reporter').ReporterOptions} */
4
+ const jestAllure2ReporterOptions = {
5
+ testCase: {
6
+ labels: {
7
+ package: ({ filePath }) => filePath.slice(1).join('/'),
8
+ testMethod: ({ testCase }) => testCase.fullName,
9
+ tag: ['unit'],
10
+ },
11
+ },
12
+ };
13
+
14
+ /** @type {import('@jest/types').Config.InitialOptions} */
15
+ module.exports = {
16
+ setupFiles: [
17
+ '<rootDir>/__tests__/setupJest.js'
18
+ ],
19
+ testEnvironment: DEBUG ? 'node' : 'jest-allure2-reporter/environment-node',
20
+ testRunner: 'jest-circus/runner',
21
+ roots: [
22
+ 'node_modules',
23
+ 'local-cli',
24
+ 'src',
25
+ 'runners'
26
+ ],
27
+ testPathIgnorePatterns: [
28
+ '/node_modules/',
29
+ 'local-cli/test.js'
30
+ ],
31
+ coveragePathIgnorePatterns: [
32
+ '/node_modules/',
33
+ '__tests__',
34
+ '.test.js$',
35
+ '.mock.js$',
36
+ 'index.js',
37
+ 'internals.js',
38
+ 'local-cli/utils',
39
+ 'src/environmentFactory',
40
+ 'src/android/espressoapi',
41
+ 'src/artifacts/factories/index.js',
42
+ 'src/artifacts/providers/index.js',
43
+ 'src/artifacts/log',
44
+ 'src/artifacts/screenshot',
45
+ 'src/artifacts/video',
46
+ 'src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js',
47
+ 'src/devices/allocation/drivers/android/emulator/patchAvdSkinConfig.js',
48
+ 'src/devices/allocation/.*AllocDriver.js',
49
+ 'src/devices/allocation/drivers/ios',
50
+ 'src/devices/allocation/factories',
51
+ 'src/devices/allocation/factories/drivers',
52
+ 'src/devices/cookies',
53
+ 'src/devices/common/drivers/android/exec/ADB.js',
54
+ 'src/devices/common/drivers/android/emulator/exec/EmulatorExec.js',
55
+ 'src/devices/common/drivers/android/tools/EmulatorTelnet.js',
56
+ 'src/devices/common/drivers/ios/tools',
57
+ 'src/devices/runtime/drivers/android/AndroidDriver.js',
58
+ 'src/devices/runtime/drivers/android/emulator/EmulatorDriver.js',
59
+ 'src/devices/runtime/drivers/DeviceDriverBase.js',
60
+ 'src/devices/runtime/drivers/ios',
61
+ 'src/devices/runtime/factories',
62
+ 'src/devices/runtime/factories/drivers',
63
+ 'src/devices/validation/EnvironmentValidatorBase.js',
64
+ 'src/devices/validation/factories',
65
+ 'src/matchers/factories',
66
+ 'src/utils/appdatapath.js',
67
+ 'src/utils/debug.js',
68
+ 'src/utils/environment.js',
69
+ 'src/utils/logger.js',
70
+ 'src/utils/pipeCommands.js',
71
+ 'src/utils/pressAnyKey.js',
72
+ 'src/utils/shellUtils.js',
73
+ 'runners/jest/reporters',
74
+ 'runners/jest/testEnvironment',
75
+ 'src/DetoxWorker.js',
76
+ 'src/logger/utils/streamUtils.js',
77
+ 'src/realms'
78
+ ],
79
+ resetMocks: true,
80
+ resetModules: true,
81
+ reporters: [
82
+ 'default',
83
+ [
84
+ 'jest-allure2-reporter',
85
+ jestAllure2ReporterOptions,
86
+ ]
87
+ ],
88
+ coverageReporters: [
89
+ 'html',
90
+ 'json',
91
+ 'text',
92
+ 'clover',
93
+ [
94
+ 'lcov',
95
+ {
96
+ projectRoot: '..'
97
+ }
98
+ ]
99
+ ],
100
+ coverageThreshold: {
101
+ global: {
102
+ statements: 100,
103
+ branches: 100,
104
+ functions: 100,
105
+ lines: 100
106
+ }
107
+ }
108
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "detox",
3
3
  "description": "E2E tests and automation for mobile",
4
- "version": "20.13.0",
4
+ "version": "20.13.1-smoke.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -51,7 +51,7 @@
51
51
  "eslint-plugin-node": "^11.1.0",
52
52
  "eslint-plugin-unicorn": "^47.0.0",
53
53
  "jest": "^28.1.3",
54
- "jest-allure2-reporter": "^1.2.1",
54
+ "jest-allure2-reporter": "2.0.0-alpha.3",
55
55
  "mockdate": "^2.0.1",
56
56
  "prettier": "^2.4.1",
57
57
  "react-native": "0.71.10",
@@ -106,104 +106,8 @@
106
106
  "engines": {
107
107
  "node": ">=14.5.0"
108
108
  },
109
- "jest": {
110
- "setupFiles": [
111
- "<rootDir>/__tests__/setupJest.js"
112
- ],
113
- "testEnvironment": "node",
114
- "testRunner": "jest-circus/runner",
115
- "roots": [
116
- "node_modules",
117
- "local-cli",
118
- "src",
119
- "runners"
120
- ],
121
- "testPathIgnorePatterns": [
122
- "/node_modules/",
123
- "local-cli/test.js"
124
- ],
125
- "coveragePathIgnorePatterns": [
126
- "/node_modules/",
127
- "__tests__",
128
- ".test.js$",
129
- ".mock.js$",
130
- "index.js",
131
- "internals.js",
132
- "local-cli/utils",
133
- "src/environmentFactory",
134
- "src/android/espressoapi",
135
- "src/artifacts/factories/index.js",
136
- "src/artifacts/providers/index.js",
137
- "src/artifacts/log",
138
- "src/artifacts/screenshot",
139
- "src/artifacts/video",
140
- "src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js",
141
- "src/devices/allocation/drivers/android/emulator/patchAvdSkinConfig.js",
142
- "src/devices/allocation/.*AllocDriver.js",
143
- "src/devices/allocation/drivers/ios",
144
- "src/devices/allocation/factories",
145
- "src/devices/allocation/factories/drivers",
146
- "src/devices/cookies",
147
- "src/devices/common/drivers/android/exec/ADB.js",
148
- "src/devices/common/drivers/android/emulator/exec/EmulatorExec.js",
149
- "src/devices/common/drivers/android/tools/EmulatorTelnet.js",
150
- "src/devices/common/drivers/ios/tools",
151
- "src/devices/runtime/drivers/android/AndroidDriver.js",
152
- "src/devices/runtime/drivers/android/emulator/EmulatorDriver.js",
153
- "src/devices/runtime/drivers/DeviceDriverBase.js",
154
- "src/devices/runtime/drivers/ios",
155
- "src/devices/runtime/factories",
156
- "src/devices/runtime/factories/drivers",
157
- "src/devices/validation/EnvironmentValidatorBase.js",
158
- "src/devices/validation/factories",
159
- "src/matchers/factories",
160
- "src/utils/appdatapath.js",
161
- "src/utils/debug.js",
162
- "src/utils/environment.js",
163
- "src/utils/logger.js",
164
- "src/utils/pipeCommands.js",
165
- "src/utils/pressAnyKey.js",
166
- "src/utils/shellUtils.js",
167
- "runners/jest/reporters",
168
- "runners/jest/testEnvironment",
169
- "src/DetoxWorker.js",
170
- "src/logger/utils/streamUtils.js",
171
- "src/realms"
172
- ],
173
- "resetMocks": true,
174
- "resetModules": true,
175
- "reporters": [
176
- "default",
177
- [
178
- "jest-allure2-reporter",
179
- {
180
- "getEnvironmentInfo": false
181
- }
182
- ]
183
- ],
184
- "coverageReporters": [
185
- "html",
186
- "json",
187
- "text",
188
- "clover",
189
- [
190
- "lcov",
191
- {
192
- "projectRoot": ".."
193
- }
194
- ]
195
- ],
196
- "coverageThreshold": {
197
- "global": {
198
- "statements": 100,
199
- "branches": 100,
200
- "functions": 100,
201
- "lines": 100
202
- }
203
- }
204
- },
205
109
  "browserslist": [
206
110
  "node 14"
207
111
  ],
208
- "gitHead": "72e85a2fe078a2a721628255249410423fc5c1ac"
112
+ "gitHead": "d43265d95231032ed53eea6d0ef87d689d61c5e8"
209
113
  }
@@ -1 +1,21 @@
1
- module.exports = require('./reporters/DetoxReporter');
1
+ /** @typedef {import('@jest/reporters').Reporter} Reporter */
2
+
3
+ const {
4
+ DetoxIPCReporter,
5
+ DetoxReporterDispatcher,
6
+ DetoxSummaryReporter,
7
+ DetoxVerboseReporter,
8
+ } = require('./reporters');
9
+
10
+ /** @implements {Reporter} */
11
+ class DetoxReporter extends DetoxReporterDispatcher {
12
+ constructor(globalConfig) {
13
+ super(globalConfig, {
14
+ DetoxSummaryReporter,
15
+ DetoxVerboseReporter,
16
+ DetoxIPCReporter,
17
+ });
18
+ }
19
+ }
20
+
21
+ module.exports = DetoxReporter;
@@ -0,0 +1,34 @@
1
+ const { config, reportTestResults } = require('../../../internals');
2
+
3
+ /** @typedef {import('@jest/reporters').Reporter} Reporter */
4
+
5
+ /** @implements {Partial<Reporter>} */
6
+ class DetoxIPCReporter {
7
+ /**
8
+ * @param {Set<import('@jest/reporters').TestContext>} testContexts
9
+ * @param {import('@jest/reporters').AggregatedResult} aggregatedResult
10
+ */
11
+ async onRunComplete(testContexts, aggregatedResult) {
12
+ const lostTests = aggregatedResult.numTotalTestSuites - aggregatedResult.testResults.length;
13
+
14
+ await reportTestResults(aggregatedResult.testResults.map(r => ({
15
+ success: !r.failureMessage,
16
+ testFilePath: r.testFilePath,
17
+ testExecError: r.testExecError,
18
+ isPermanentFailure: lostTests > 0 || this._isPermanentFailure(r),
19
+ })));
20
+ }
21
+
22
+ /**
23
+ * @param {import('@jest/test-result').TestResult} testResult
24
+ */
25
+ _isPermanentFailure(testResult) {
26
+ if (config.testRunner.jest.retryAfterCircusRetries) {
27
+ return false;
28
+ }
29
+
30
+ return testResult.testResults.some(r => r.status === 'failed' && r.invocations > 1);
31
+ }
32
+ }
33
+
34
+ module.exports = DetoxIPCReporter;
@@ -0,0 +1,144 @@
1
+ /** @typedef {import('@jest/reporters').Reporter} Reporter */
2
+
3
+ const { config, unsafe_conductEarlyTeardown } = require('../../../internals');
4
+ const Deferred = require('../../../src/utils/Deferred');
5
+
6
+ /** @implements {Reporter} */
7
+ class DetoxReporterDispatcher {
8
+ /**
9
+ * @param {import('@jest/types').Config.GlobalConfig} globalConfig
10
+ * @param {Record<string, new (globalConfig: import('@jest/types').Config.GlobalConfig) => Partial<Reporter>>} reporters
11
+ */
12
+ constructor(globalConfig, reporters) {
13
+ this._bail = globalConfig.bail;
14
+ /** @type {Deferred | null} */
15
+ this._lastRunComplete = null;
16
+ /** @type {Set<string>} */
17
+ this._pendingTestFiles = new Set();
18
+ /** @type {Promise<any> | null} */
19
+ this._onRunCompletePromise = null;
20
+ /** @type {Partial<Reporter>[]} */
21
+ this._reporters = Object.values(reporters).map((Reporter) => new Reporter(globalConfig));
22
+ }
23
+
24
+ getLastError() {
25
+ for (const reporter of this._reporters) {
26
+ let error = typeof reporter.getLastError === 'function'
27
+ ? reporter.getLastError()
28
+ : undefined;
29
+
30
+ if (error) {
31
+ return error;
32
+ }
33
+ }
34
+
35
+ return;
36
+ }
37
+
38
+ onRunStart(aggregatedResult, options) {
39
+ return this._dispatch('onRunStart', aggregatedResult, options);
40
+ }
41
+
42
+ onTestFileStart(test) {
43
+ this._pendingTestFiles.add(test.path);
44
+ return this._dispatch(['onTestFileStart', 'onTestStart'], test);
45
+ }
46
+
47
+ onTestStart(test) {
48
+ // Legacy method
49
+ return this.onTestFileStart(test);
50
+ }
51
+
52
+ // NEW! Supported only since Jest 29.6.0
53
+ onTestCaseStart(test, testCaseStartInfo) {
54
+ return this._dispatch('onTestCaseStart', test, testCaseStartInfo);
55
+ }
56
+
57
+ onTestCaseResult(test, testCaseResult) {
58
+ return this._dispatch('onTestCaseResult', test, testCaseResult);
59
+ }
60
+
61
+ async onTestFileResult(test, testResult, aggregatedResult) {
62
+ this._pendingTestFiles.delete(test.path);
63
+
64
+ await this._dispatch(['onTestFileResult', 'onTestResult'], test, testResult, aggregatedResult);
65
+
66
+ if (this._lastRunComplete && this._pendingTestFiles.size === 0) {
67
+ this._lastRunComplete.resolve(aggregatedResult);
68
+ }
69
+ }
70
+
71
+ onTestResult(test, testResult, aggregatedResult) {
72
+ // Legacy method
73
+ return this.onTestFileResult(test, testResult, aggregatedResult);
74
+ }
75
+
76
+ onRunComplete(testContexts, aggregatedResult) {
77
+ if (!this._lastRunComplete) {
78
+ // Both `_lastRunComplete` and `_onRunCompletePromise` are used to prevent
79
+ // a bug in Jest, where `onRunComplete` is called multiple times when
80
+ // Jest runs with `--bail` and multiple workers, and `onRunComplete`
81
+ // is implemented as an asynchronous long-running operation.
82
+ this._lastRunComplete = this._pendingTestFiles.size === 0
83
+ ? Deferred.resolved(aggregatedResult)
84
+ : new Deferred();
85
+ }
86
+
87
+ if (!this._onRunCompletePromise) {
88
+ this._onRunCompletePromise = this._doRunComplete(testContexts, aggregatedResult);
89
+ }
90
+
91
+ return this._onRunCompletePromise;
92
+ }
93
+
94
+ /**
95
+ * @private
96
+ * @param {Set<import('@jest/reporters').TestContext>} testContexts
97
+ * @param {import('@jest/test-result').AggregatedResult} aggregatedResult
98
+ * @returns {Promise<void>}
99
+ */
100
+ async _doRunComplete(testContexts, aggregatedResult) {
101
+ const earlyTeardown = this._bail > 0 && aggregatedResult.numFailedTests >= this._bail;
102
+ if (earlyTeardown) {
103
+ const lostTests = aggregatedResult.numTotalTestSuites - aggregatedResult.testResults.length;
104
+ if (lostTests > 0 && config.testRunner.retries > 0) {
105
+ console.warn(
106
+ 'Jest aborted the test execution before all scheduled test files have been reported.\n' +
107
+ 'If you want to retry the whole test run, please disable Jest\'s --bail option.'
108
+ );
109
+ }
110
+
111
+ await unsafe_conductEarlyTeardown();
112
+ }
113
+
114
+ await this._lastRunComplete.promise;
115
+ await this._dispatch('onRunComplete', testContexts, aggregatedResult);
116
+ }
117
+
118
+ /**
119
+ * @private
120
+ * @param {string | string[]} rawMethodNames
121
+ * @param {...any} args
122
+ * @returns {Promise<void>}
123
+ */
124
+ _dispatch(rawMethodNames, ...args) {
125
+ const methodNames = Array.isArray(rawMethodNames)
126
+ ? rawMethodNames
127
+ : [rawMethodNames];
128
+
129
+ const maybePromises = [];
130
+
131
+ for (const reporter of this._reporters) {
132
+ for (const methodName of methodNames) {
133
+ if (typeof reporter[methodName] === 'function') {
134
+ maybePromises.push(reporter[methodName](...args));
135
+ break;
136
+ }
137
+ }
138
+ }
139
+
140
+ return Promise.all(maybePromises).then(() => void 0);
141
+ }
142
+ }
143
+
144
+ module.exports = DetoxReporterDispatcher;
@@ -0,0 +1,16 @@
1
+ /** @typedef {import('@jest/reporters').Reporter} Reporter */
2
+
3
+ const resolveFrom = require('resolve-from');
4
+ /** @type {new (globalConfig: any) => import('@jest/reporters').SummaryReporter} */
5
+ const SummaryReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).SummaryReporter;
6
+
7
+ /** @implements {Partial<Reporter>} */
8
+ class DetoxSummaryReporter {
9
+ constructor(globalConfig) {
10
+ if (globalConfig.reporters.every(([name]) => name !== 'default' && name !== 'summary')) {
11
+ return new SummaryReporter(globalConfig);
12
+ }
13
+ }
14
+ }
15
+
16
+ module.exports = DetoxSummaryReporter;
@@ -0,0 +1,16 @@
1
+ /** @typedef {import('@jest/reporters').Reporter} Reporter */
2
+
3
+ const resolveFrom = require('resolve-from');
4
+ /** @type {new (globalConfig: any) => import('@jest/reporters').VerboseReporter} */
5
+ const VerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).VerboseReporter;
6
+
7
+ /** @implements {Partial<Reporter>} */
8
+ class DetoxVerboseReporter {
9
+ constructor(globalConfig) {
10
+ if (globalConfig.reporters.every(([name]) => name !== 'default')) {
11
+ return new VerboseReporter(globalConfig);
12
+ }
13
+ }
14
+ }
15
+
16
+ module.exports = DetoxVerboseReporter;
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ DetoxIPCReporter: require('./DetoxIPCReporter'),
3
+ DetoxReporterDispatcher: require('./DetoxReporterDispatcher'),
4
+ DetoxSummaryReporter: require('./DetoxSummaryReporter'),
5
+ DetoxVerboseReporter: require('./DetoxVerboseReporter'),
6
+ };
@@ -20,12 +20,10 @@ class SimulatorAllocDriver {
20
20
  * @param {import('../../DeviceRegistry')} options.deviceRegistry
21
21
  * @param {DetoxInternals.RuntimeConfig} options.detoxConfig
22
22
  * @param {import('../../../common/drivers/ios/tools/AppleSimUtils')} options.applesimutils
23
- * @param {import('./SimulatorLauncher')} options.simulatorLauncher
24
23
  */
25
- constructor({ detoxConfig, deviceRegistry, applesimutils, simulatorLauncher }) {
24
+ constructor({ detoxConfig, deviceRegistry, applesimutils }) {
26
25
  this._deviceRegistry = deviceRegistry;
27
26
  this._applesimutils = applesimutils;
28
- this._simulatorLauncher = simulatorLauncher;
29
27
  this._launchInfo = {};
30
28
  this._shouldShutdown = detoxConfig.behavior.cleanup.shutdownDevice;
31
29
  }
@@ -61,7 +59,7 @@ class SimulatorAllocDriver {
61
59
  async postAllocate(deviceCookie) {
62
60
  const { udid } = deviceCookie;
63
61
  const { deviceConfig } = this._launchInfo[udid];
64
- await this._simulatorLauncher.launch(udid, deviceConfig.type, deviceConfig.bootArgs, deviceConfig.headless);
62
+ await this._applesimutils.boot(udid, deviceConfig.bootArgs, deviceConfig.headless);
65
63
 
66
64
  return {
67
65
  id: udid,
@@ -105,7 +103,7 @@ class SimulatorAllocDriver {
105
103
  */
106
104
  async _doShutdown(udid) {
107
105
  try {
108
- await this._simulatorLauncher.shutdown(udid);
106
+ await this._applesimutils.shutdown(udid);
109
107
  } catch (err) {
110
108
  log.warn({ err }, `Failed to shutdown simulator ${udid}`);
111
109
  }
@@ -9,11 +9,8 @@ class IosSimulator extends DeviceAllocatorFactory {
9
9
  const DeviceRegistry = require('../../../devices/allocation/DeviceRegistry');
10
10
  const deviceRegistry = new DeviceRegistry({ sessionId: detoxSession.id });
11
11
 
12
- const SimulatorLauncher = require('../drivers/ios/SimulatorLauncher');
13
- const simulatorLauncher = new SimulatorLauncher({ applesimutils, eventEmitter });
14
-
15
12
  const SimulatorAllocDriver = require('../drivers/ios/SimulatorAllocDriver');
16
- return new SimulatorAllocDriver({ detoxConfig, deviceRegistry, applesimutils, simulatorLauncher });
13
+ return new SimulatorAllocDriver({ detoxConfig, deviceRegistry, applesimutils });
17
14
  }
18
15
  }
19
16
 
@@ -14,7 +14,6 @@ const IosDriver = require('./IosDriver');
14
14
 
15
15
  /**
16
16
  * @typedef SimulatorDriverDeps { DeviceDriverDeps }
17
- * @property simulatorLauncher { SimulatorLauncher }
18
17
  * @property applesimutils { AppleSimUtils }
19
18
  */
20
19
 
@@ -38,7 +37,6 @@ class SimulatorDriver extends IosDriver {
38
37
  this._bootArgs = bootArgs;
39
38
  this._headless = headless;
40
39
  this._deviceName = `${udid} (${this._type})`;
41
- this._simulatorLauncher = deps.simulatorLauncher;
42
40
  this._applesimutils = deps.applesimutils;
43
41
  }
44
42
 
@@ -150,9 +148,12 @@ class SimulatorDriver extends IosDriver {
150
148
  }
151
149
 
152
150
  async resetContentAndSettings() {
153
- await this._simulatorLauncher.shutdown(this.udid);
151
+ await this.emitter.emit('beforeShutdownDevice', { deviceId: this.udid });
152
+ await this._applesimutils.shutdown(this.udid);
153
+ await this.emitter.emit('shutdownDevice', { deviceId: this.udid });
154
154
  await this._applesimutils.resetContentAndSettings(this.udid);
155
- await this._simulatorLauncher.launch(this.udid, this._type, this._bootArgs, this._headless);
155
+ await this._applesimutils.boot(this.udid, this._bootArgs, this._headless);
156
+ await this.emitter.emit('bootDevice', { deviceId: this.udid });
156
157
  }
157
158
 
158
159
  getLogsPaths() {
@@ -7,11 +7,9 @@ class RuntimeDriverFactoryIos extends RuntimeDeviceFactory {
7
7
  const AppleSimUtils = require('../../../devices/common/drivers/ios/tools/AppleSimUtils');
8
8
  const applesimutils = new AppleSimUtils();
9
9
 
10
- const SimulatorLauncher = require('../../allocation/drivers/ios/SimulatorLauncher');
11
10
  return {
12
11
  ...commonDeps,
13
12
  applesimutils,
14
- simulatorLauncher: new SimulatorLauncher({ applesimutils, eventEmitter }),
15
13
  };
16
14
  }
17
15
  }
@@ -1 +0,0 @@
1
- 0709a8a30b2cc4c27244a2257ac28ed7
@@ -1 +0,0 @@
1
- 08f017a03aa160bead65af9b208ea95857ac9697
@@ -1 +0,0 @@
1
- 5cc49445c8f5440e5e5ed8d2d95e4827fb1ab4796d20e32ab30d7151da661ce7
@@ -1 +0,0 @@
1
- 7360ab285d19450619f38c7da9985fda6514d382f903e87a2af9d4e0204a0250851c412a045da6ce04cc932e9addf7c131fd5147889975be20910e2fdc64e88f
@@ -1 +0,0 @@
1
- 972fa81d6c5d9f0eb6edc63765bf01af
@@ -1 +0,0 @@
1
- 1ea26448826d4701a7dce9d2c0c24355853ad9d7
@@ -1 +0,0 @@
1
- 6b2f9a8186f2eef1075910eae28c189ac2030561520277e503e3a696f3c977e2
@@ -1 +0,0 @@
1
- eae9264b4d57f78a80ecffae3c85e157a2cd1df1b2259c0edc93f5c22d305a004216c5e9e6b35a1415fab6ba14a4f6667acd2eac4d5c6ae5a7a410ee85ca2c7c
@@ -1 +0,0 @@
1
- 0ff20c1510b97ba80b15a438ce65bddc
@@ -1 +0,0 @@
1
- 449b07e6bb8435baef57e3d0839e68b5f7f85af5
@@ -1 +0,0 @@
1
- c3347ddd7b4e4a94c60c55c079451ea219e050f7c69b8dbc7b59a453d2398e67
@@ -1 +0,0 @@
1
- ebcf7f52b7e34a391174fc8850879e39a3e3f8f8ccfa0a417937680187461d5b41f7811933ca5ca088c554ae7a4e8d8cb2198375fdbb55680888aac561c71f64
@@ -1 +0,0 @@
1
- 293aa59dd07a84b7a1bd7c4dc2bffe16
@@ -1 +0,0 @@
1
- 144cef7278f92d8e7798cae134d8f93136492080
@@ -1 +0,0 @@
1
- a1062bb5feb8cb7210de7f0e2c36d8a219f8d4065377c9ced13ae55d7eb13220
@@ -1,154 +0,0 @@
1
- const resolveFrom = require('resolve-from');
2
- /** @type {new (globalConfig: any) => import('@jest/reporters').VerboseReporter} */
3
- const JestVerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).VerboseReporter;
4
- /** @type {new (globalConfig: any) => import('@jest/reporters').SummaryReporter} */
5
- const SummaryReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).SummaryReporter;
6
-
7
- const { config, reportTestResults, unsafe_conductEarlyTeardown, cleanup } = require('../../../internals');
8
- const Deferred = require('../../../src/utils/Deferred');
9
-
10
- class DetoxReporter extends JestVerboseReporter {
11
- constructor(globalConfig) {
12
- super(globalConfig);
13
-
14
- /** @type {Deferred | null} */
15
- this._lastRunComplete = null;
16
- /** @type {Set<string>} */
17
- this._pendingTestFiles = new Set();
18
- /** @type {Promise<any> | null} */
19
- this._runCompletePromise = null;
20
- /** @type {import('@jest/reporters').SummaryReporter | null} */
21
- this._summaryReporter = this._initSummaryReporter();
22
- }
23
-
24
- onRunStart(aggregatedResults, options) {
25
- super.onRunStart(aggregatedResults, options);
26
-
27
- if (this._summaryReporter) {
28
- this._summaryReporter.onRunStart(aggregatedResults, options);
29
- }
30
- }
31
-
32
- onTestFileStart(test) {
33
- this._pendingTestFiles.add(test.path);
34
-
35
- // @ts-ignore Precaution in case Jest migrates to the new signature
36
- if (typeof super.onTestFileStart === 'function') {
37
- // @ts-ignore
38
- super.onTestFileStart(test);
39
- } else {
40
- super.onTestStart(test);
41
- }
42
- }
43
-
44
- onTestFileResult(test, testResult, aggregatedResult) {
45
- this._pendingTestFiles.delete(test.path);
46
-
47
- // @ts-ignore Precaution in case Jest migrates to the new signature
48
- if (typeof super.onTestFileResult === 'function') {
49
- // @ts-ignore
50
- super.onTestFileResult(test, testResult, aggregatedResult);
51
- } else {
52
- super.onTestResult(test, testResult, aggregatedResult);
53
- }
54
-
55
- if (this._lastRunComplete && this._pendingTestFiles.size === 0) {
56
- this._lastRunComplete.resolve(aggregatedResult);
57
- }
58
- }
59
-
60
- /**
61
- * @param {Set<import('@jest/reporters').TestContext>} testContexts
62
- * @param {import('@jest/reporters').AggregatedResult} aggregatedResult
63
- * @returns {Promise<any> | null}
64
- */
65
- // @ts-ignore We need to use the complete signature, not the one from the base class
66
- onRunComplete(testContexts, aggregatedResult) {
67
- if (!this._runCompletePromise) {
68
- // Both `_lastRunComplete` and `_runCompletePromise` are used to prevent
69
- // a bug in Jest, where `onRunComplete` is called multiple times when
70
- // Jest runs with `--bail` and multiple workers, and `onRunComplete`
71
- // is implemented as an asynchronous long-running operation.
72
- this._lastRunComplete = this._pendingTestFiles.size === 0
73
- ? Deferred.resolved(aggregatedResult)
74
- : new Deferred();
75
-
76
- this._runCompletePromise = this._onRunComplete(testContexts, aggregatedResult).catch(err => {
77
- console.error(err);
78
- throw err;
79
- });
80
- }
81
-
82
- return this._runCompletePromise;
83
- }
84
-
85
- /**
86
- * @param {Set<import('@jest/reporters').TestContext>} testContexts
87
- * @param {import('@jest/reporters').AggregatedResult} aggregatedResult
88
- * @returns {Promise<any> | null}
89
- */
90
- async _onRunComplete(testContexts, { numFailedTests }) {
91
- const bail = this._globalConfig.bail;
92
- const earlyTeardown = bail > 0 && numFailedTests >= bail;
93
- if (earlyTeardown) {
94
- await unsafe_conductEarlyTeardown();
95
- }
96
-
97
- const aggregatedResult = await this._lastRunComplete.promise;
98
- const lostTests = aggregatedResult.numTotalTestSuites - aggregatedResult.testResults.length;
99
-
100
- // @ts-expect-error TS2554
101
- super.onRunComplete(testContexts, aggregatedResult);
102
-
103
- if (earlyTeardown && lostTests > 0 && config.testRunner.retries > 0) {
104
- console.warn(
105
- 'Jest aborted the test execution before all scheduled test files have been reported.\n' +
106
- 'This brings us to a dilemma: retry the whole test run, or retry only known failed test files.\n' +
107
- 'Both options are bad in their own way, this is why we have decided to not support this edge case.\n' +
108
- 'If you want to retry the whole test run, please disable Jest\'s --bail option.'
109
- );
110
- }
111
-
112
- await reportTestResults(aggregatedResult.testResults.map(r => ({
113
- success: !r.failureMessage,
114
- testFilePath: r.testFilePath,
115
- testExecError: r.testExecError,
116
- isPermanentFailure: lostTests > 0 || this._isPermanentFailure(r),
117
- })));
118
-
119
- if (this._summaryReporter) {
120
- this._summaryReporter.onRunComplete(testContexts, aggregatedResult);
121
- }
122
-
123
- if (earlyTeardown) {
124
- await cleanup();
125
- }
126
- }
127
-
128
- /**
129
- * @returns {import('@jest/reporters').SummaryReporter | null}
130
- * @private
131
- */
132
- _initSummaryReporter() {
133
- /** @type {(config: import('@jest/types').Config.ReporterConfig) => boolean} */
134
- const isSummaryReporter = (config) => config[0] === 'summary';
135
- if (this._globalConfig.reporters.some(isSummaryReporter)) {
136
- return null;
137
- }
138
-
139
- return new SummaryReporter(this._globalConfig);
140
- }
141
-
142
- /**
143
- * @param {import('@jest/test-result').TestResult} testResult
144
- */
145
- _isPermanentFailure(testResult) {
146
- if (config.testRunner.jest.retryAfterCircusRetries) {
147
- return false;
148
- }
149
-
150
- return testResult.testResults.some(r => r.status === 'failed' && r.invocations > 1);
151
- }
152
- }
153
-
154
- module.exports = DetoxReporter;
@@ -1,25 +0,0 @@
1
- class SimulatorLauncher {
2
- constructor({ applesimutils, eventEmitter }) {
3
- this._applesimutils = applesimutils;
4
- this._eventEmitter = eventEmitter;
5
- }
6
-
7
- async launch(udid, type, bootArgs, headless) {
8
- const coldBoot = await this._applesimutils.boot(udid, bootArgs, headless);
9
- return coldBoot;
10
- }
11
-
12
- async shutdown(udid) {
13
- if (this._eventEmitter) {
14
- await this._eventEmitter.emit('beforeShutdownDevice', { deviceId: udid });
15
- }
16
-
17
- await this._applesimutils.shutdown(udid);
18
-
19
- if (this._eventEmitter) {
20
- await this._eventEmitter.emit('shutdownDevice', { deviceId: udid });
21
- }
22
- }
23
- }
24
-
25
- module.exports = SimulatorLauncher;