detox 20.3.0 → 20.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0-javadoc.jar → 20.5.0/detox-20.5.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0-sources.jar → 20.5.0/detox-20.5.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0.pom → 20.5.0/detox-20.5.0.pom} +7 -1
  12. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0.pom.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0.pom.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0.pom.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.5.0/detox-20.5.0.pom.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  17. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  18. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  19. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  20. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  21. package/Detox-ios-src.tbz +0 -0
  22. package/Detox-ios.tbz +0 -0
  23. package/android/detox/build.gradle +4 -1
  24. package/index.d.ts +2 -0
  25. package/local-cli/cli.js +1 -1
  26. package/local-cli/init.js +2 -2
  27. package/local-cli/start.js +49 -0
  28. package/local-cli/startCommand/AppStartCommand.js +65 -0
  29. package/local-cli/testCommand/TestRunnerCommand.js +29 -0
  30. package/local-cli/testCommand/builder.js +5 -0
  31. package/package.json +3 -2
  32. package/src/configuration/collectCliConfig.js +1 -0
  33. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-javadoc.jar.md5 +0 -1
  34. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-javadoc.jar.sha1 +0 -1
  35. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-javadoc.jar.sha256 +0 -1
  36. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-javadoc.jar.sha512 +0 -1
  37. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-sources.jar.md5 +0 -1
  38. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-sources.jar.sha1 +0 -1
  39. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-sources.jar.sha256 +0 -1
  40. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0-sources.jar.sha512 +0 -1
  41. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0.pom.md5 +0 -1
  42. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0.pom.sha1 +0 -1
  43. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0.pom.sha256 +0 -1
  44. package/Detox-android/com/wix/detox/20.3.0/detox-20.3.0.pom.sha512 +0 -1
  45. /package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0.aar → 20.5.0/detox-20.5.0.aar} +0 -0
  46. /package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0.aar.md5 → 20.5.0/detox-20.5.0.aar.md5} +0 -0
  47. /package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0.aar.sha1 → 20.5.0/detox-20.5.0.aar.sha1} +0 -0
  48. /package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0.aar.sha256 → 20.5.0/detox-20.5.0.aar.sha256} +0 -0
  49. /package/Detox-android/com/wix/detox/{20.3.0/detox-20.3.0.aar.sha512 → 20.5.0/detox-20.5.0.aar.sha512} +0 -0
@@ -0,0 +1 @@
1
+ 312ca2e6d26a005375c7d31f7a489b60
@@ -0,0 +1 @@
1
+ 80debe0a3a1ed317173f56f92cbfd1f108f3fb6c
@@ -0,0 +1 @@
1
+ ceeb582236c99040fb116be37c6eb97c67ecdf91f8cdd1d5dade614a3180375c
@@ -0,0 +1 @@
1
+ 08dcd64b4e65c486a7fe0d4a59b23e4b9ffc037b4afad03db9cb820b97867e22693d929b7e896f41c11c8a4e3e0d0dbbc11799a69f438d46aeeb8ebb8b157056
@@ -0,0 +1 @@
1
+ 643850c6dad298f22d9ce657af17dd5c
@@ -0,0 +1 @@
1
+ e483f7ab88c2b2d5882d1c825155856c61ba059f
@@ -0,0 +1 @@
1
+ 2ee1a851c254668619e44df167d0b1d86bd63edb9414a239f1fcea380c39a077
@@ -0,0 +1 @@
1
+ 3446a90564f2af11a6b6221f114ccd8786044080e222ed698fef6a92d706faed154fdaa976c0dca162db58976170a60b7bc05d5e931a1b1bbf02ff8292d0c47c
@@ -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.3.0</version>
6
+ <version>20.5.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>
@@ -54,6 +54,12 @@
54
54
  </exclusion>
55
55
  </exclusions>
56
56
  </dependency>
57
+ <dependency>
58
+ <groupId>org.hamcrest</groupId>
59
+ <artifactId>hamcrest</artifactId>
60
+ <version>2.2</version>
61
+ <scope>compile</scope>
62
+ </dependency>
57
63
  <dependency>
58
64
  <groupId>androidx.test</groupId>
59
65
  <artifactId>rules</artifactId>
@@ -0,0 +1 @@
1
+ e6f8b937b6573484515f78adcc830096
@@ -0,0 +1 @@
1
+ 59e4b461ba168a526c1c629fb29ded508472e732
@@ -0,0 +1 @@
1
+ b455e110295c40221b1620cfe6ffc905fc9623b36a5f38fabf52316def1f9749
@@ -0,0 +1 @@
1
+ 766004a843b60ee7b385f26324762d8f18d35064324fb7ab5c24e59816869745401dafbfc3517ff55948527fd0411a2b9382b3f29de8aa6756e61df58a3c416c
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.3.0</latest>
7
- <release>20.3.0</release>
6
+ <latest>20.5.0</latest>
7
+ <release>20.5.0</release>
8
8
  <versions>
9
- <version>20.3.0</version>
9
+ <version>20.5.0</version>
10
10
  </versions>
11
- <lastUpdated>20230226195437</lastUpdated>
11
+ <lastUpdated>20230304081841</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 4912285f2cf394f3d1d5c67514c907d1
1
+ 7ef4d0c49e15b7641923a73bf049cb58
@@ -1 +1 @@
1
- 5a1d2fa06aaf1fc06746b27afd3e9f7d0b4fe150
1
+ 7612e7860c59949c39e71cd063713aa3a3fc9022
@@ -1 +1 @@
1
- 46023c58541873b523a78e4d3027e394d30d54c8831f0132dd2d32b2dd278c84
1
+ 1c0015aa8cdb2feaedfea04b080a429eac94a39c39220f67eb46dcd205ff136b
@@ -1 +1 @@
1
- 4ca4a9eab20c1130c64ab7678869b866a8a568c2f32785d35f2332897745cd6085f9d1db1ea36e2d161c3a60abd0d8f8868e38266e063108971c937326a1b897
1
+ 585e914dd526582d4dc520c65d85c69d5ec7ad6abcac74db26832293e300ecf64241d0d1a4814b2b9627125cc02ffbee8964b23783a016233c6ba5676989952c
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
@@ -99,6 +99,9 @@ dependencies {
99
99
  because 'Android datepicker support'
100
100
  exclude group: "org.checkerframework", module: "checker"
101
101
  }
102
+ api('org.hamcrest:hamcrest:2.2') {
103
+ because 'See https://github.com/wix/Detox/issues/3920. Need to force hamcrest 2.2 win in battle of 2.2 vs. 1.3 (specified by Espresso).'
104
+ }
102
105
  api('androidx.test:rules:1.4.0') {
103
106
  because 'of ActivityTestRule. Needed by users *and* internally used by Detox.'
104
107
  }
@@ -145,7 +148,7 @@ dependencies {
145
148
  // Spek (https://spekframework.org/setup-android)
146
149
  if (rootProject.hasProperty('isOfficialDetoxLib') ||
147
150
  rootProject.hasProperty('isOfficialDetoxApp')) {
148
-
151
+
149
152
  apply plugin: 'de.mannodermaus.android-junit5'
150
153
 
151
154
  android {
package/index.d.ts CHANGED
@@ -331,6 +331,7 @@ declare global {
331
331
  binaryPath: string;
332
332
  bundleId?: string;
333
333
  build?: string;
334
+ start?: string;
334
335
  launchArgs?: Record<string, any>;
335
336
  }
336
337
 
@@ -339,6 +340,7 @@ declare global {
339
340
  binaryPath: string;
340
341
  bundleId?: string;
341
342
  build?: string;
343
+ start?: string;
342
344
  testBinaryPath?: string;
343
345
  launchArgs?: Record<string, any>;
344
346
  /**
package/local-cli/cli.js CHANGED
@@ -12,7 +12,7 @@ const { isErrorAlreadyLogged } = require('./utils/cliErrorHandling');
12
12
  yargs
13
13
  .scriptName('detox')
14
14
  .parserConfiguration({
15
- 'boolean-negation': false,
15
+ 'boolean-negation': true,
16
16
  'camel-case-expansion': false,
17
17
  'dot-notation': false,
18
18
  'duplicate-arguments-array': false,
package/local-cli/init.js CHANGED
@@ -93,13 +93,13 @@ function createDefaultConfigurations() {
93
93
  'android.debug': {
94
94
  type: 'android.apk',
95
95
  binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
96
- build: 'cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -',
96
+ build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
97
97
  reversePorts: [8081],
98
98
  },
99
99
  'android.release': {
100
100
  type: 'android.apk',
101
101
  binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
102
- build: 'cd android ; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release ; cd -',
102
+ build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
103
103
  },
104
104
  },
105
105
  devices: {
@@ -0,0 +1,49 @@
1
+ const _ = require('lodash');
2
+
3
+ const detox = require('../internals');
4
+
5
+ const AppStartCommand = require('./startCommand/AppStartCommand');
6
+
7
+ module.exports.command = 'start';
8
+ module.exports.desc = 'Run app "start" scripts inside the selected configuration';
9
+ module.exports.builder = {
10
+ C: {
11
+ alias: 'config-path',
12
+ describe: 'Specify Detox config file path. If not supplied, Detox searches for .detoxrc[.js] or "detox" section in package.json',
13
+ },
14
+ c: {
15
+ alias: ['configuration'],
16
+ describe:
17
+ 'Select a local configuration from your defined configurations to extract the app "start" scripts from. If not supplied, and there\'s only one configuration, Detox will default to it',
18
+ },
19
+ f: {
20
+ alias: 'force',
21
+ describe: 'Ignore errors from the "start" scripts and proceed',
22
+ boolean: true,
23
+ }
24
+ };
25
+
26
+ module.exports.handler = async function start(argv) {
27
+ const { apps: appsConfig } = await detox.resolveConfig({ argv });
28
+ const startCommands = _(appsConfig)
29
+ .values()
30
+ .map(app => app.start)
31
+ .filter(Boolean)
32
+ .map(cmd => new AppStartCommand({
33
+ cmd,
34
+ passthrough: argv['--'],
35
+ forceSpawn: argv.force,
36
+ }))
37
+ .value();
38
+
39
+ if (startCommands.length) {
40
+ try {
41
+ await Promise.all(startCommands.map(c => c.execute()));
42
+ } catch (e) {
43
+ await Promise.allSettled(startCommands.map(c => c.stop()));
44
+ throw e;
45
+ }
46
+ } else {
47
+ detox.log.warn('No "start" commands were found in the app configs.');
48
+ }
49
+ };
@@ -0,0 +1,65 @@
1
+ const execa = require('execa');
2
+
3
+ const detox = require('../../internals');
4
+ const { DetoxRuntimeError } = require('../../src/errors');
5
+ const Deferred = require('../../src/utils/Deferred');
6
+ const log = detox.log.child({ cat: ['lifecycle', 'cli'] });
7
+
8
+ class AppStartCommand {
9
+ constructor({ cmd, passthrough = [], forceSpawn = false }) {
10
+ this._id = Math.random();
11
+ this._cmd = cmd;
12
+ this._passthrough = passthrough;
13
+ this._forceSpawn = forceSpawn;
14
+
15
+ this._cpHandle = null;
16
+ this._cpDeferred = new Deferred();
17
+ }
18
+
19
+ execute() {
20
+ const cmd = [this._cmd, ...this._passthrough].join(' ');
21
+
22
+ log.info.begin({ id: this._id }, cmd);
23
+
24
+ const onEnd = (msg, code, signal) => {
25
+ log.trace.end({ id: this._id, code, signal }, msg);
26
+ this._cpDeferred.resolve();
27
+ };
28
+
29
+ const onError = (msg, code, signal) => {
30
+ const logLevel = this._forceSpawn ? 'warn' : 'error';
31
+ log[logLevel].end({ id: this._id, code, signal }, msg);
32
+ if (this._forceSpawn) {
33
+ this._cpDeferred.resolve();
34
+ } else {
35
+ this._cpDeferred.reject(new DetoxRuntimeError(msg));
36
+ }
37
+ };
38
+
39
+ this._cpHandle = execa.command(cmd, { stdio: 'inherit', shell: true });
40
+ this._cpHandle.on('error', onError);
41
+ this._cpHandle.on('exit', (code, signal) => {
42
+ const reason = code == null ? `signal ${signal}` : `code ${code}`;
43
+ const msg = `Command exited with ${reason}: ${cmd}`;
44
+ if (signal || code === 0) {
45
+ onEnd(msg, code, signal);
46
+ } else {
47
+ onError(msg, code, signal);
48
+ }
49
+
50
+ this._cpHandle = null;
51
+ });
52
+
53
+ return this._cpDeferred.promise;
54
+ }
55
+
56
+ async stop() {
57
+ if (this._cpHandle) {
58
+ this._cpHandle.kill();
59
+ }
60
+
61
+ return this._cpDeferred.promise;
62
+ }
63
+ }
64
+
65
+ module.exports = AppStartCommand;
@@ -9,6 +9,8 @@ const log = detox.log.child({ cat: ['lifecycle', 'cli'] });
9
9
  const { printEnvironmentVariables, prependNodeModulesBinToPATH } = require('../../src/utils/envUtils');
10
10
  const { toSimplePath } = require('../../src/utils/pathUtils');
11
11
  const { escapeSpaces, useForwardSlashes } = require('../../src/utils/shellUtils');
12
+ const sleep = require('../../src/utils/sleep');
13
+ const AppStartCommand = require('../startCommand/AppStartCommand');
12
14
  const { markErrorAsLogged } = require('../utils/cliErrorHandling');
13
15
 
14
16
  const TestRunnerError = require('./TestRunnerError');
@@ -23,11 +25,14 @@ class TestRunnerCommand {
23
25
  const cliConfig = opts.config.cli;
24
26
  const deviceConfig = opts.config.device;
25
27
  const runnerConfig = opts.config.testRunner;
28
+ const appsConfig = opts.config.apps;
26
29
 
27
30
  this._argv = runnerConfig.args;
28
31
  this._retries = runnerConfig.retries;
29
32
  this._envHint = this._buildEnvHint(opts.env);
33
+ this._startCommands = this._prepareStartCommands(appsConfig, cliConfig);
30
34
  this._envFwd = {};
35
+
31
36
  if (runnerConfig.forwardEnv) {
32
37
  this._envFwd = this._buildEnvOverride(cliConfig, deviceConfig);
33
38
  Object.assign(this._envHint, this._envFwd);
@@ -38,6 +43,15 @@ class TestRunnerCommand {
38
43
  let runsLeft = 1 + this._retries;
39
44
  let launchError = null;
40
45
 
46
+ if (this._startCommands.length > 0) {
47
+ try {
48
+ await Promise.race([sleep(1000), ...this._startCommands.map(cmd => cmd.execute())]);
49
+ } catch (e) {
50
+ await Promise.allSettled(this._startCommands.map(cmd => cmd.stop()));
51
+ throw e;
52
+ }
53
+ }
54
+
41
55
  do {
42
56
  try {
43
57
  await this._spawnTestRunner();
@@ -67,6 +81,8 @@ class TestRunnerCommand {
67
81
  }
68
82
  } while (launchError && runsLeft > 0);
69
83
 
84
+ await Promise.allSettled(this._startCommands.map(cmd => cmd.stop()));
85
+
70
86
  if (launchError) {
71
87
  throw launchError;
72
88
  }
@@ -80,6 +96,19 @@ class TestRunnerCommand {
80
96
  .value();
81
97
  }
82
98
 
99
+ _prepareStartCommands(appsConfig, cliConfig) {
100
+ if (`${cliConfig.start}` === 'false') {
101
+ return [];
102
+ }
103
+
104
+ return _.values(appsConfig)
105
+ .filter(app => app.start)
106
+ .map(app => new AppStartCommand({
107
+ cmd: app.start,
108
+ forceSpawn: cliConfig.start === 'force',
109
+ }));
110
+ }
111
+
83
112
  /**
84
113
  * @param {DetoxInternals.CLIConfig} cliConfig
85
114
  * @param {Detox.DetoxDeviceConfig} deviceConfig
@@ -28,6 +28,11 @@ module.exports = {
28
28
  describe: 'Reuse existing installed app (do not delete + reinstall) for a faster run.',
29
29
  boolean: true,
30
30
  },
31
+ start: {
32
+ group: 'Execution:',
33
+ describe: 'Run app "start" scripts before running the tests. Use --no-start to disable that, and --start=force to ignore errors.',
34
+ default: true,
35
+ },
31
36
  u: {
32
37
  alias: 'cleanup',
33
38
  group: 'Execution:',
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.3.0",
4
+ "version": "20.5.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -63,6 +63,7 @@
63
63
  "caf": "^15.0.1",
64
64
  "chalk": "^2.4.2",
65
65
  "child-process-promise": "^2.2.0",
66
+ "execa": "^5.1.1",
66
67
  "find-up": "^4.1.0",
67
68
  "fs-extra": "^4.0.2",
68
69
  "funpermaproxy": "^1.1.0",
@@ -199,5 +200,5 @@
199
200
  }
200
201
  }
201
202
  },
202
- "gitHead": "c35e064d90789a9f815169b6b665c7626a8f0040"
203
+ "gitHead": "e7866370faef479abd6ff98aa1607e420d75b9ef"
203
204
  }
@@ -55,6 +55,7 @@ function collectCliConfig({ argv }) {
55
55
  useCustomLogger: asBoolean(get('use-custom-logger')),
56
56
  retries: asNumber(get('retries')),
57
57
  inspectBrk: asBoolean(get('inspect-brk')),
58
+ start: get('start'),
58
59
  }, _.isUndefined);
59
60
  }
60
61
 
@@ -1 +0,0 @@
1
- f45eea837cb2a196fab34ba5cf799b4c
@@ -1 +0,0 @@
1
- 5a52dbb1f517893fbf92da231c393b2acb00f064
@@ -1 +0,0 @@
1
- 9d4f12b046f1a8f3e62af95c6dd67a07c953640e243a7b8f367f8719465a7524
@@ -1 +0,0 @@
1
- 5588b6760c32a4efafdf96c46837f8b4e67ef3bf5aba76b279b014b2f506f33242e75132f752e59586b3a972b63376a517c0425ab140e51bff0b5e22abddd228
@@ -1 +0,0 @@
1
- afa5931e30f34c41812919f453f3f39e
@@ -1 +0,0 @@
1
- 1e014f1d37481f610de06225d1bf3b9a5bb1dbb2
@@ -1 +0,0 @@
1
- 325107fa6252c35551840f8e7c6bba2860bf81ec9841c0797a852e96e2b09b5a
@@ -1 +0,0 @@
1
- 3d1c057abb1fc73be80815e16f084f4594a0591d9e3626e14a4eca40f168aaaa8958b16f144a0978e6908cf4ca09d4c5d14c372d1922a2c9be21deff098ecd70
@@ -1 +0,0 @@
1
- 703310d6b13bda87aa9d2150d38e8c97
@@ -1 +0,0 @@
1
- 3211a734fbe94c25b45514761fd1618071b0d7d8
@@ -1 +0,0 @@
1
- 9bdc1b00ebbc7e37c4691460ae8a71644c7d65398bd6c9945d2e09a40d524ee0
@@ -1 +0,0 @@
1
- 172ce985d77f28d635d3e9ad24e93045e150f4748a68e923adaf5c6a623cf1c0ff2bfda1f6f318fd4bbfdeeb6147e346700f2cc6e96af4123c547b57a5803141