detox 20.0.11-prerelease.0 → 20.0.13-is-hittable-over-master.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0-javadoc.jar → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0-sources.jar → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0.aar → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.aar} +0 -0
  12. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0.aar.md5 → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.aar.md5} +0 -0
  13. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0.aar.sha1 → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.aar.sha1} +0 -0
  14. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0.aar.sha256 → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.aar.sha256} +0 -0
  15. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0.aar.sha512 → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.aar.sha512} +0 -0
  16. package/Detox-android/com/wix/detox/{20.0.11-prerelease.0/detox-20.0.11-prerelease.0.pom → 20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.0.13-is-hittable-over-master.0/detox-20.0.13-is-hittable-over-master.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/index.d.ts +18 -2
  29. package/internals.d.ts +36 -14
  30. package/local-cli/cli.js +7 -5
  31. package/local-cli/init.js +1 -1
  32. package/local-cli/reset-lock-file.js +16 -0
  33. package/local-cli/test.test.js +58 -14
  34. package/local-cli/testCommand/TestRunnerCommand.js +10 -3
  35. package/package.json +2 -2
  36. package/runners/jest/reporters/DetoxReporter.js +22 -2
  37. package/runners/jest/testEnvironment/index.js +83 -82
  38. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +9 -24
  39. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
  40. package/src/configuration/composeRunnerConfig.js +3 -1
  41. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +4 -4
  42. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +1 -1
  43. package/src/ipc/IPCClient.js +9 -5
  44. package/src/ipc/IPCServer.js +17 -13
  45. package/src/ipc/SessionState.js +2 -4
  46. package/src/realms/DetoxContext.js +2 -2
  47. package/src/realms/DetoxInternalsFacade.js +1 -1
  48. package/src/realms/DetoxPrimaryContext.js +6 -8
  49. package/src/realms/DetoxSecondaryContext.js +2 -2
  50. package/src/symbols.js +2 -2
  51. package/src/utils/Timer.js +55 -38
  52. package/src/utils/errorUtils.js +20 -0
  53. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-javadoc.jar.md5 +0 -1
  54. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-javadoc.jar.sha1 +0 -1
  55. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-javadoc.jar.sha256 +0 -1
  56. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-javadoc.jar.sha512 +0 -1
  57. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-sources.jar.md5 +0 -1
  58. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-sources.jar.sha1 +0 -1
  59. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-sources.jar.sha256 +0 -1
  60. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0-sources.jar.sha512 +0 -1
  61. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0.pom.md5 +0 -1
  62. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0.pom.sha1 +0 -1
  63. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0.pom.sha256 +0 -1
  64. package/Detox-android/com/wix/detox/20.0.11-prerelease.0/detox-20.0.11-prerelease.0.pom.sha512 +0 -1
@@ -0,0 +1 @@
1
+ 32e7dad08149fd68b710d1a52304849b9887761dcabb1a07aa85662abe51ad54
@@ -0,0 +1 @@
1
+ 2d79955bcaef50813752fcd8b859cb404b1b98034c47af0b61d4e2d406712db8b4dc69d56f13dca18dcb54a4cd3297dbf9589440894d0254033ea32526c89f65
@@ -0,0 +1 @@
1
+ 44973b24e24924c26fa6df03b9b9e39a5e59f6dd94c755426582873715332637
@@ -0,0 +1 @@
1
+ 8d6633f64860a1e9765e8a9a3ff36bdc2b068c1f73166f0566d1699ad93b4d1e92c492e3c7c03840443baf8e9f5bff195cc54000132194dda2b793c8b02f9b92
@@ -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.0.11-prerelease.0</version>
6
+ <version>20.0.13-is-hittable-over-master.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
+ e9d4e60ac7b43c06e34b18c37175f77da03d6739c9ead58d1ba647c6a71f93a7
@@ -0,0 +1 @@
1
+ 4663d530e10cab54de779e5730c59cec7345b7a4f99e0d04f16f71b59f2e98a0f40a025c101b0c389dfaa863f0de249492e9e914ba964667f14572d34d48d1d3
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.0.11-prerelease.0</latest>
7
- <release>20.0.11-prerelease.0</release>
6
+ <latest>20.0.13-is-hittable-over-master.0</latest>
7
+ <release>20.0.13-is-hittable-over-master.0</release>
8
8
  <versions>
9
- <version>20.0.11-prerelease.0</version>
9
+ <version>20.0.13-is-hittable-over-master.0</version>
10
10
  </versions>
11
- <lastUpdated>20220930144845</lastUpdated>
11
+ <lastUpdated>20221103130525</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 7298eb41c092e9d6471b11d8c4072549
1
+ a3c33c552dbf92dc59b9e463233a84d5
@@ -1 +1 @@
1
- d59581aa200215423697a398b1e30952dbcad89d
1
+ afe6331be318d4580debfc0895acec66a037f0c6
@@ -1 +1 @@
1
- 964eb89f375a8ac845a5d63eaa867d544a7fdc4b0cd9abe539417827895a9b6a
1
+ 572d1a034b59858231a34c4e05bfd5c6f910236573db97c33e582c6404dc516a
@@ -1 +1 @@
1
- 8b8c26e1906aff908931afb6a7e095bd0d4eb3b08df4061c5b3645c0a6c9e1dc3cc0e9415f7e7a4b5bd7aec76c1e8f2de11388067b1e4d33cfcc2d6eb595933e
1
+ 6e6785e4ad075200449611e8aa0bbe4dfa904808797d20f5dc2dfe599ee480226fc53f6242a6d85cf6922a0efdcbff28cd7b1b4b1515c4d87a41918978e3785c
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
package/index.d.ts CHANGED
@@ -11,6 +11,7 @@
11
11
  import { BunyanDebugStreamOptions } from 'bunyan-debug-stream';
12
12
 
13
13
  declare global {
14
+ const detox: Detox.DetoxExportWrapper;
14
15
  const device: Detox.DetoxExportWrapper['device'];
15
16
  const element: Detox.DetoxExportWrapper['element'];
16
17
  const waitFor: Detox.DetoxExportWrapper['waitFor'];
@@ -20,6 +21,7 @@ declare global {
20
21
 
21
22
  namespace NodeJS {
22
23
  interface Global {
24
+ detox: Detox.DetoxExportWrapper;
23
25
  device: Detox.DetoxExportWrapper['device'];
24
26
  element: Detox.DetoxExportWrapper['element'];
25
27
  waitFor: Detox.DetoxExportWrapper['waitFor'];
@@ -137,9 +139,13 @@ declare global {
137
139
  */
138
140
  jest?: {
139
141
  /**
140
- * Device init timeout
142
+ * Environment setup timeout
141
143
  */
142
- initTimeout?: number | undefined;
144
+ setupTimeout?: number | undefined;
145
+ /**
146
+ * Environment teardown timeout
147
+ */
148
+ teardownTimeout?: number | undefined;
143
149
  /**
144
150
  * Insist on CLI-based retry mechanism even when the failed tests have been handled
145
151
  * by jest.retryTimes(n) mechanism from Jest Circus.
@@ -152,6 +158,16 @@ declare global {
152
158
  * Retries count. Zero means a single attempt to run tests.
153
159
  */
154
160
  retries?: number;
161
+ /**
162
+ * When true, tells Detox CLI to cancel next retrying if it gets
163
+ * at least one report about a permanent test suite failure.
164
+ * Has no effect, if {@link DetoxTestRunnerConfig#retries} is
165
+ * undefined or set to zero.
166
+ *
167
+ * @default false
168
+ * @see {DetoxInternals.DetoxTestFileReport#isPermanentFailure}
169
+ */
170
+ bail?: boolean;
155
171
  /**
156
172
  * Custom handler to process --inspect-brk CLI flag.
157
173
  * Use it when you rely on another test runner than Jest.
package/internals.d.ts CHANGED
@@ -54,14 +54,13 @@ declare global {
54
54
  onRunFinish(event: unknown): Promise<void>;
55
55
 
56
56
  /**
57
- * Reports to Detox CLI about failed tests that could have been re-run if
57
+ * Reports to Detox CLI about passed and failed test files.
58
+ * The failed test files might be re-run again if
58
59
  * {@link Detox.DetoxTestRunnerConfig#retries} is set to a non-zero.
59
60
  *
60
- * @param testFilePaths array of failed test files' paths
61
- * @param permanent whether the failure is permanent, and the tests
62
- * should not be re-run.
61
+ * @param testResults - reports about test files
63
62
  */
64
- reportFailedTests(testFilePaths: string[], permanent?: boolean): Promise<void>;
63
+ reportTestResults(testResults: DetoxTestFileReport[]): Promise<void>;
65
64
  // endregion
66
65
 
67
66
  readonly config: RuntimeConfig;
@@ -92,7 +91,7 @@ declare global {
92
91
  testRunnerArgv: Record<string, unknown>;
93
92
  override: Partial<Detox.DetoxConfig>;
94
93
  /** @inheritDoc */
95
- global: NodeJS.Global;
94
+ global: NodeJS.Global | {};
96
95
  /**
97
96
  * Worker ID. Used to distinguish allocated workers in parallel test execution environment.
98
97
  *
@@ -111,7 +110,7 @@ declare global {
111
110
  * {@link DetoxInternals.Facade#setup} might override {@link Console} methods
112
111
  * to integrate it with Detox loggeing subsystem.
113
112
  */
114
- global: NodeJS.Global;
113
+ global: NodeJS.Global | {};
115
114
  /**
116
115
  * Worker ID. Used to distinguish allocated workers in parallel test execution environment.
117
116
  *
@@ -120,25 +119,48 @@ declare global {
120
119
  workerId: string;
121
120
  };
122
121
 
122
+ type DetoxTestFileReport = {
123
+ /**
124
+ * Global or relative path to the failed test file.
125
+ */
126
+ testFilePath: string;
127
+ /**
128
+ * Whether the test passed or not.
129
+ */
130
+ success: boolean;
131
+ /**
132
+ * Top-level error if the entire test file failed.
133
+ */
134
+ testExecError?: { name?: string; message: string; stack?: string; };
135
+ /**
136
+ * If the test failed, it should tell whether the failure is permanent.
137
+ * Permanent failure means that the test file should not be re-run.
138
+ *
139
+ * @default false
140
+ * @see {Detox.DetoxTestRunnerConfig#retries}
141
+ */
142
+ isPermanentFailure?: boolean;
143
+ };
144
+
123
145
  type SessionState = Readonly<{
124
146
  /**
125
147
  * Randomly generated ID for the entire Detox test session, including retries.
126
148
  */
127
149
  id: string;
128
150
  /**
129
- * Permanently failed test file paths.
151
+ * Results of test file executions. Primarily used for Detox CLI retry mechanism.
130
152
  */
131
- failedTestFiles: string[];
132
- /**
133
- * Failed test file paths suggested to retry via Detox CLI mechanism.
134
- */
135
- testFilesToRetry: string[];
153
+ testResults: DetoxTestFileReport[];
136
154
  /**
137
155
  * Retry index of the test session: 0..retriesCount.
138
156
  */
139
157
  testSessionIndex: number;
140
158
  /**
141
- * TODO
159
+ * Count of Detox contexts with a worker installed.
160
+ * Oversimplified, it reflects the count of allocated devices in the current test session.
161
+ *
162
+ * @see {Facade#init}
163
+ * @see {Facade#installWorker}
142
164
  */
143
165
  workersCount: number;
144
166
  }>;
package/local-cli/cli.js CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ const fs = require('fs');
3
+
4
+ const _ = require('lodash');
2
5
  const yargs = require('yargs');
3
6
 
7
+ const logger = require('../internals').log.child({ cat: 'cli' });
4
8
  const DetoxError = require('../src/errors/DetoxError');
5
- const logger = require('../src/utils/logger').child({ cat: 'cli' });
6
9
 
7
10
  yargs
8
11
  .scriptName('detox')
@@ -25,12 +28,11 @@ yargs
25
28
  .wrap(yargs.terminalWidth() * 0.9)
26
29
  .fail(function(msg, err, program) {
27
30
  if (err) {
28
- const lines = DetoxError.format(err).split('\n');
29
- for (const line of lines) {
30
- logger.error(line);
31
- }
31
+ logger.error(DetoxError.format(err));
32
32
  // eslint-disable-next-line no-console
33
33
  console.error('');
34
+ // @ts-ignore
35
+ _.attempt(() => fs.unlinkSync(logger.file));
34
36
  // eslint-disable-next-line no-process-exit
35
37
  process.exit(1);
36
38
  }
package/local-cli/init.js CHANGED
@@ -76,7 +76,7 @@ function createDefaultConfigurations() {
76
76
  config: 'e2e/jest.config.js',
77
77
  },
78
78
  jest: {
79
- initTimeout: 120000,
79
+ setupTimeout: 120000,
80
80
  },
81
81
  },
82
82
  apps: {
@@ -0,0 +1,16 @@
1
+ const { log } = require('../internals');
2
+ const DeviceRegistry = require('../src/devices/DeviceRegistry');
3
+ const { getDetoxLibraryRootPath } = require('../src/utils/environment');
4
+
5
+
6
+ module.exports.command = 'reset-lock-file';
7
+ module.exports.desc = 'Resets all Detox lock files. Useful when you need to run multiple `detox test` commands in parallel with --keepLockFile.';
8
+
9
+ module.exports.handler = async function resetLockFile() {
10
+ await Promise.all([
11
+ DeviceRegistry.forIOS().reset(),
12
+ DeviceRegistry.forAndroid().reset(),
13
+ ]);
14
+
15
+ log.info(`Cleaned lock files from: ${getDetoxLibraryRootPath()}`);
16
+ };
@@ -8,6 +8,8 @@ jest.mock('../src/devices/DeviceRegistry');
8
8
  jest.mock('../src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory');
9
9
  jest.mock('./utils/jestInternals');
10
10
 
11
+ const cp = require('child_process');
12
+ const cpSpawn = cp.spawn;
11
13
  const os = require('os');
12
14
  const path = require('path');
13
15
 
@@ -28,6 +30,10 @@ describe('CLI', () => {
28
30
  let GenyDeviceRegistryFactory;
29
31
  let jestInternals;
30
32
 
33
+ afterEach(() => {
34
+ cp.spawn = cpSpawn;
35
+ });
36
+
31
37
  beforeEach(() => {
32
38
  _cliCallDump = undefined;
33
39
  _env = process.env;
@@ -139,11 +145,28 @@ describe('CLI', () => {
139
145
  });
140
146
 
141
147
  test.each([['-R'], ['--retries']])('%s <value> should execute unsuccessful run N extra times', async (__retries) => {
148
+ function toTestResult(testFilePath) {
149
+ return {
150
+ testFilePath,
151
+ success: false,
152
+ isPermanentFailure: false,
153
+ };
154
+ }
155
+
142
156
  const context = require('../internals');
143
- context.session.testFilesToRetry = ['e2e/failing1.test.js', 'e2e/failing2.test.js'];
144
- context.session.testFilesToRetry.splice = jest.fn()
145
- .mockImplementationOnce(() => ['e2e/failing1.test.js', 'e2e/failing2.test.js'])
146
- .mockImplementationOnce(() => ['e2e/failing2.test.js']);
157
+
158
+ jest.spyOn(cp, 'spawn')
159
+ .mockImplementationOnce((...args) => {
160
+ context.session.testResults = ['e2e/failing1.test.js', 'e2e/failing2.test.js'].map(toTestResult);
161
+ return cpSpawn(...args);
162
+ })
163
+ .mockImplementationOnce((...args) => {
164
+ context.session.testResults = ['e2e/failing2.test.js'].map(toTestResult);
165
+ return cpSpawn(...args);
166
+ })
167
+ .mockImplementationOnce((...args) => {
168
+ return cpSpawn(...args);
169
+ });
147
170
 
148
171
  mockExitCode(1);
149
172
 
@@ -154,18 +177,35 @@ describe('CLI', () => {
154
177
  expect(cliCall(2).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', 'e2e/failing2.test.js']);
155
178
  });
156
179
 
157
- test.each([['-R'], ['--retries']])('%s <value> should bail if has permanently failed tests', async (__retries) => {
158
- const context = require('../internals');
159
- context.session.failedTestFiles = ['e2e/failing1.test.js'];
160
- context.session.testFilesToRetry = ['e2e/failing2.test.js'];
180
+ describe('when there are permanently failed tests', () => {
181
+ beforeEach(() => {
182
+ const context = require('../internals');
183
+ context.session.testResults = ['e2e/failing1.test.js', 'e2e/failing2.test.js'].map((testFilePath, index) => ({
184
+ testFilePath,
185
+ success: false,
186
+ isPermanentFailure: index > 0,
187
+ }));
161
188
 
162
- mockExitCode(1);
189
+ mockExitCode(1);
190
+ });
163
191
 
164
- await run(__retries, 2).catch(_.noop);
192
+ test.each([['-R'], ['--retries']])('%s <value> should not bail by default', async (__retries) => {
193
+ await run(__retries, 2).catch(_.noop);
165
194
 
166
- expect(cliCall(0).env).not.toHaveProperty('DETOX_RERUN_INDEX');
167
- expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json']);
168
- expect(cliCall(1)).toBe(null);
195
+ expect(cliCall(0).env).not.toHaveProperty('DETOX_RERUN_INDEX');
196
+ expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json']);
197
+ expect(cliCall(1).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', 'e2e/failing1.test.js']);
198
+ // note that it does not take the permanently failed test
199
+ });
200
+
201
+ test.each([['-R'], ['--retries']])('%s <value> should bail if configured', async (__retries) => {
202
+ detoxConfig.testRunner.bail = true;
203
+ await run(__retries, 2).catch(_.noop);
204
+
205
+ expect(cliCall(0).env).not.toHaveProperty('DETOX_RERUN_INDEX');
206
+ expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json']);
207
+ expect(cliCall(1)).toBe(null);
208
+ });
169
209
  });
170
210
 
171
211
  test.each([['-R'], ['--retries']])('%s <value> should not restart test runner if there are no failing tests paths', async (__retries) => {
@@ -178,7 +218,11 @@ describe('CLI', () => {
178
218
 
179
219
  test.each([['-R'], ['--retries']])('%s <value> should retain -- <...explicitPassthroughArgs>', async (__retries) => {
180
220
  const context = require('../internals');
181
- context.session.testFilesToRetry = ['tests/failing.test.js'];
221
+ context.session.testResults = [{
222
+ testFilePath: 'tests/failing.test.js',
223
+ success: false,
224
+ isPermanentFailure: false,
225
+ }];
182
226
 
183
227
  mockExitCode(1);
184
228
 
@@ -99,13 +99,20 @@ class TestRunnerCommand {
99
99
  } catch (e) {
100
100
  launchError = e;
101
101
 
102
- const { failedTestFiles, testFilesToRetry } = detox.session;
103
- if (!_.isEmpty(failedTestFiles) || _.isEmpty(testFilesToRetry)) {
102
+ const failedTestFiles = detox.session.testResults.filter(r => !r.success);
103
+
104
+ const { bail } = detox.config.testRunner;
105
+ if (bail && failedTestFiles.some(r => r.isPermanentFailure)) {
106
+ throw e;
107
+ }
108
+
109
+ const testFilesToRetry = failedTestFiles.filter(r => !r.isPermanentFailure).map(r => r.testFilePath);
110
+ if (_.isEmpty(testFilesToRetry)) {
104
111
  throw e;
105
112
  }
106
113
 
107
114
  if (--runsLeft > 0) {
108
- this._argv._ = testFilesToRetry.splice(0, Infinity);
115
+ this._argv._ = testFilesToRetry;
109
116
  // @ts-ignore
110
117
  detox.session.testSessionIndex++; // it is always a primary context, so we can update it
111
118
  }
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.0.11-prerelease.0",
4
+ "version": "20.0.13-is-hittable-over-master.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -184,5 +184,5 @@
184
184
  }
185
185
  }
186
186
  },
187
- "gitHead": "bd5998c15067ee02fc7cd65ae28e55847a4387c9"
187
+ "gitHead": "210fce372789081e9b91b217afd693519bf30c66"
188
188
  }
@@ -1,5 +1,25 @@
1
- const { VerboseReporter: JestVerboseReporter } = require('@jest/reporters'); // eslint-disable-line node/no-extraneous-require
1
+ const resolveFrom = require('resolve-from');
2
+ /** @type {typeof import('@jest/reporters').VerboseReporter} */
3
+ const JestVerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).VerboseReporter;
2
4
 
3
- class DetoxReporter extends JestVerboseReporter {}
5
+ const { config, reportTestResults } = require('../../../internals');
6
+
7
+ class DetoxReporter extends JestVerboseReporter {
8
+ /**
9
+ * @param {import('@jest/test-result').TestResult} testResult
10
+ */
11
+ async onTestResult(test, testResult, results) {
12
+ await super.onTestResult(test, testResult, results);
13
+
14
+ await reportTestResults([{
15
+ success: !testResult.failureMessage,
16
+ testFilePath: testResult.testFilePath,
17
+ testExecError: testResult.testExecError,
18
+ isPermanentFailure: config.testRunner.jest.retryAfterCircusRetries
19
+ ? false
20
+ : testResult.testResults.some(r => r.invocations > 1)
21
+ }]);
22
+ }
23
+ }
4
24
 
5
25
  module.exports = DetoxReporter;