detox 20.1.0-next-is-hittable-check.0 → 20.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar → 20.1.0/detox-20.1.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar → 20.1.0/detox-20.1.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom → 20.1.0/detox-20.1.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/android/build.gradle +0 -1
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
- package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
- package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
- package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
- package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +2 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +1 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
- package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
- package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
- package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
- package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
- package/index.d.ts +102 -18
- package/internals.d.ts +34 -9
- package/local-cli/cli.js +6 -3
- package/local-cli/init.js +1 -1
- package/local-cli/test.js +6 -6
- package/local-cli/testCommand/TestRunnerCommand.js +97 -94
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/package.json +18 -15
- package/runners/deprecation.js +42 -44
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/reporters/DetoxReporter.js +21 -10
- package/runners/jest/testEnvironment/index.js +57 -41
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/src/DetoxWorker.js +95 -49
- package/src/android/interactions/native.js +3 -2
- package/src/artifacts/ArtifactsManager.js +6 -6
- package/src/artifacts/utils/temporaryPath.js +32 -2
- package/src/client/actions/SyncStatusSchema.json +21 -0
- package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
- package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeRunnerConfig.js +5 -4
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +4 -0
- package/src/devices/runtime/RuntimeDevice.js +3 -3
- package/src/errors/DetoxConfigErrorComposer.js +6 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +3 -2
- package/src/ipc/IPCClient.js +26 -17
- package/src/ipc/IPCServer.js +11 -3
- package/src/ipc/SessionState.js +11 -11
- package/src/logger/DetoxLogger.js +63 -43
- package/src/logger/index.js +1 -0
- package/src/logger/utils/BunyanLogger.js +50 -7
- package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
- package/src/logger/utils/DetoxLogFinalizer.js +166 -0
- package/src/logger/utils/MessageStack.js +17 -6
- package/src/logger/utils/ThreadDispatcher.js +5 -25
- package/src/logger/utils/customConsoleLogger.js +22 -5
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +3 -1
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +14 -25
- package/src/realms/DetoxContext.js +11 -7
- package/src/realms/DetoxInternalsFacade.js +0 -6
- package/src/realms/DetoxPrimaryContext.js +42 -87
- package/src/realms/DetoxSecondaryContext.js +8 -12
- package/src/utils/argparse.js +11 -0
- package/src/utils/logger.js +1 -1
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
- package/local-cli/build.test.js +0 -104
- package/local-cli/run-server.test.js +0 -23
- package/local-cli/test.test.js +0 -569
- package/runners/jest/deprecation.js +0 -25
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
- package/src/configuration/utils/warnings.js +0 -12
- package/src/logger/utils/streamUtils.js +0 -240
- package/src/utils/trace.js +0 -3
@@ -5,7 +5,7 @@ const { getJestBooleanArgs } = require('../utils/jestInternals');
|
|
5
5
|
const { simpleUnquote, extractKnownKeys, disengageBooleanArgs } = require('../utils/yargsUtils');
|
6
6
|
|
7
7
|
const testCommandArgs = require('./builder');
|
8
|
-
const { DETOX_ARGV_OVERRIDE_NOTICE
|
8
|
+
const { DETOX_ARGV_OVERRIDE_NOTICE } = require('./warnings');
|
9
9
|
|
10
10
|
function applyEnvironmentVariableAddendum(argv, yargs) {
|
11
11
|
if (process.env.DETOX_ARGV_OVERRIDE) {
|
@@ -13,12 +13,13 @@ function applyEnvironmentVariableAddendum(argv, yargs) {
|
|
13
13
|
|
14
14
|
const { _: positional, '--': passthrough, ...named } = yargs.parse(process.env.DETOX_ARGV_OVERRIDE);
|
15
15
|
|
16
|
-
if (positional) {
|
16
|
+
if (!_.isEmpty(positional)) {
|
17
|
+
/* istanbul ignore next */
|
17
18
|
argv._ = argv._ || [];
|
18
19
|
argv._.push(...positional.map(simpleUnquote));
|
19
20
|
}
|
20
21
|
|
21
|
-
if (passthrough) {
|
22
|
+
if (!_.isEmpty(passthrough)) {
|
22
23
|
argv['--'] = argv['--'] || [];
|
23
24
|
argv['--'].push(...passthrough.map(simpleUnquote));
|
24
25
|
}
|
@@ -29,14 +30,6 @@ function applyEnvironmentVariableAddendum(argv, yargs) {
|
|
29
30
|
return argv;
|
30
31
|
}
|
31
32
|
|
32
|
-
function warnDeviceAppLaunchArgsDeprecation(argv) {
|
33
|
-
if (argv['device-boot-args'] && process.argv.some(a => a.startsWith('--device-launch-args'))) {
|
34
|
-
log.warn(DEVICE_LAUNCH_ARGS_DEPRECATION);
|
35
|
-
}
|
36
|
-
|
37
|
-
return argv;
|
38
|
-
}
|
39
|
-
|
40
33
|
/**
|
41
34
|
* @param {Record<string, *>} argv
|
42
35
|
* @returns {{
|
@@ -64,12 +57,10 @@ function splitArgv(argv) {
|
|
64
57
|
// noinspection JSUnusedGlobalSymbols
|
65
58
|
module.exports = {
|
66
59
|
applyEnvironmentVariableAddendum,
|
67
|
-
warnDeviceAppLaunchArgsDeprecation,
|
68
60
|
splitArgv,
|
69
61
|
};
|
70
62
|
|
71
63
|
module.exports.default = [
|
72
64
|
applyEnvironmentVariableAddendum,
|
73
|
-
warnDeviceAppLaunchArgsDeprecation,
|
74
65
|
splitArgv,
|
75
66
|
];
|
@@ -1,5 +1,3 @@
|
|
1
|
-
const { DEVICE_LAUNCH_ARGS_DEPRECATION } = require('../../src/configuration/utils/warnings');
|
2
|
-
|
3
1
|
const DETOX_ARGV_OVERRIDE_NOTICE = `
|
4
2
|
_____ _____ ___________
|
5
3
|
/ ___|_ _| _ | ___ \\ $DETOX_ARGV_OVERRIDE is detected
|
@@ -22,5 +20,4 @@ const DETOX_ARGV_OVERRIDE_NOTICE = `
|
|
22
20
|
|
23
21
|
module.exports = {
|
24
22
|
DETOX_ARGV_OVERRIDE_NOTICE,
|
25
|
-
DEVICE_LAUNCH_ARGS_DEPRECATION,
|
26
23
|
};
|
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.1.0
|
4
|
+
"version": "20.1.0",
|
5
5
|
"bin": {
|
6
6
|
"detox": "local-cli/cli.js"
|
7
7
|
},
|
@@ -35,8 +35,8 @@
|
|
35
35
|
"@types/bunyan": "^1.8.8",
|
36
36
|
"@types/child-process-promise": "^2.2.1",
|
37
37
|
"@types/fs-extra": "^9.0.13",
|
38
|
-
"@types/jest": "^
|
39
|
-
"@types/node": "^
|
38
|
+
"@types/jest": "^28.1.8",
|
39
|
+
"@types/node": "^14.18.33",
|
40
40
|
"@types/node-ipc": "^9.2.0",
|
41
41
|
"@types/ws": "^7.4.0",
|
42
42
|
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
@@ -46,10 +46,10 @@
|
|
46
46
|
"eslint-plugin-no-only-tests": "^2.6.0",
|
47
47
|
"eslint-plugin-node": "^11.1.0",
|
48
48
|
"eslint-plugin-unicorn": "^39.0.0",
|
49
|
-
"jest": "^28.
|
49
|
+
"jest": "^28.1.3",
|
50
50
|
"mockdate": "^2.0.1",
|
51
51
|
"prettier": "1.7.0",
|
52
|
-
"react-native": "0.69.
|
52
|
+
"react-native": "0.69.7",
|
53
53
|
"react-native-codegen": "^0.0.8",
|
54
54
|
"typescript": "^4.5.2",
|
55
55
|
"wtfnode": "^0.9.1"
|
@@ -58,12 +58,12 @@
|
|
58
58
|
"ajv": "^8.6.3",
|
59
59
|
"bunyan": "^1.8.12",
|
60
60
|
"bunyan-debug-stream": "^3.1.0",
|
61
|
+
"caf": "^15.0.1",
|
61
62
|
"chalk": "^2.4.2",
|
62
63
|
"child-process-promise": "^2.2.0",
|
63
|
-
"duplexify": "^4.1.2",
|
64
64
|
"find-up": "^4.1.0",
|
65
65
|
"fs-extra": "^4.0.2",
|
66
|
-
"funpermaproxy": "^1.0
|
66
|
+
"funpermaproxy": "^1.1.0",
|
67
67
|
"glob": "^8.0.3",
|
68
68
|
"ini": "^1.3.4",
|
69
69
|
"json-cycle": "^1.3.0",
|
@@ -81,7 +81,6 @@
|
|
81
81
|
"signal-exit": "^3.0.3",
|
82
82
|
"stream-json": "^1.7.4",
|
83
83
|
"strip-ansi": "^6.0.1",
|
84
|
-
"tail": "^2.0.0",
|
85
84
|
"telnet-client": "1.2.8",
|
86
85
|
"tempfile": "^2.0.0",
|
87
86
|
"trace-event-lib": "^1.3.1",
|
@@ -100,7 +99,7 @@
|
|
100
99
|
}
|
101
100
|
},
|
102
101
|
"engines": {
|
103
|
-
"node": ">=
|
102
|
+
"node": ">=14.5.0"
|
104
103
|
},
|
105
104
|
"jest": {
|
106
105
|
"setupFiles": [
|
@@ -159,7 +158,11 @@
|
|
159
158
|
"src/utils/pipeCommands.js",
|
160
159
|
"src/utils/pressAnyKey.js",
|
161
160
|
"src/utils/shellUtils.js",
|
162
|
-
"runners/jest
|
161
|
+
"runners/jest/reporters",
|
162
|
+
"runners/jest/testEnvironment",
|
163
|
+
"src/DetoxWorker.js",
|
164
|
+
"src/logger/utils/streamUtils.js",
|
165
|
+
"src/realms"
|
163
166
|
],
|
164
167
|
"resetMocks": true,
|
165
168
|
"resetModules": true,
|
@@ -177,12 +180,12 @@
|
|
177
180
|
],
|
178
181
|
"coverageThreshold": {
|
179
182
|
"global": {
|
180
|
-
"statements":
|
181
|
-
"branches":
|
182
|
-
"functions":
|
183
|
-
"lines":
|
183
|
+
"statements": 100,
|
184
|
+
"branches": 100,
|
185
|
+
"functions": 100,
|
186
|
+
"lines": 100
|
184
187
|
}
|
185
188
|
}
|
186
189
|
},
|
187
|
-
"gitHead": "
|
190
|
+
"gitHead": "57097c7301cae2460bd3b36c1749c4048d84dd39"
|
188
191
|
}
|
package/runners/deprecation.js
CHANGED
@@ -1,47 +1,45 @@
|
|
1
1
|
const chalk = require('chalk');
|
2
2
|
|
3
3
|
// @ts-ignore
|
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
|
-
throw
|
46
|
-
'\n\nPlease follow the new Jest setup guide:\nhttps://github.com/wix/Detox/blob/master/docs/Guide.Jest.md\n\n'
|
47
|
-
), { stack: '' });
|
4
|
+
const bold = chalk.bold;
|
5
|
+
|
6
|
+
function getMaxWidth(text) {
|
7
|
+
const lines = text.split('\n');
|
8
|
+
return lines.reduce((acc, line) => Math.max(acc, line.length), 0);
|
9
|
+
}
|
10
|
+
|
11
|
+
function centerText(text, maxWidth = getMaxWidth(text)) {
|
12
|
+
return text
|
13
|
+
.split('\n')
|
14
|
+
.map(line => {
|
15
|
+
const padStart = Math.max(0, Math.floor((maxWidth - line.length) / 2));
|
16
|
+
const padEnd = Math.max(0, maxWidth - line.length - padStart);
|
17
|
+
return ' '.repeat(padStart) + line + ' '.repeat(padEnd);
|
18
|
+
})
|
19
|
+
.join('\n');
|
20
|
+
}
|
21
|
+
|
22
|
+
const header = `\
|
23
|
+
========================= THE NEW JOURNEY BEGINS =============================`;
|
24
|
+
|
25
|
+
console.error(centerText(`\
|
26
|
+
|
27
|
+
${bold(header)}
|
28
|
+
|
29
|
+
https://wix.github.io/Detox/docs/guide/migration
|
30
|
+
|
31
|
+
Sorry to say that Detox 20 comes without old adapters for Jest.
|
32
|
+
You have to rearrange your init code before you can continue your journey.
|
33
|
+
|
34
|
+
Navigate to the link and follow the migration guide steps.
|
35
|
+
|
36
|
+
Sincerely yours,
|
37
|
+
Detox team.
|
38
|
+
|
39
|
+
${bold(header)}
|
40
|
+
|
41
|
+
`, header.length));
|
42
|
+
|
43
|
+
const error = new Error('\nPlease follow the migration guide:\nhttps://wix.github.io/Detox/docs/guide/migration\n\n');
|
44
|
+
error.stack = '';
|
45
|
+
throw error;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
declare module 'detox/runners/jest' {
|
2
|
+
import type NodeEnvironment from 'jest-environment-node';
|
3
|
+
|
4
|
+
export function globalSetup(): Promise<void>;
|
5
|
+
export function globalTeardown(): Promise<void>;
|
6
|
+
|
7
|
+
export type DetoxCircusListenerConstructorOpts = {
|
8
|
+
readonly env: DetoxCircusEnvironment;
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @example
|
13
|
+
* class CustomListener implements DetoxCircusListener {
|
14
|
+
* constructor(opts: DetoxCircusListenerConstructorOpts) {
|
15
|
+
* console.log('Current test path is:', opts.env.testPath);
|
16
|
+
* }
|
17
|
+
* }
|
18
|
+
*/
|
19
|
+
export interface DetoxCircusListener {
|
20
|
+
start_describe_definition?(event: unknown, state: unknown): void;
|
21
|
+
finish_describe_definition?(event: unknown, state: unknown): void;
|
22
|
+
add_hook?(event: unknown, state: unknown): void;
|
23
|
+
add_test?(event: unknown, state: unknown): void;
|
24
|
+
error?(event: unknown, state: unknown): void;
|
25
|
+
|
26
|
+
setup?(event: unknown, state: unknown): void | Promise<void>;
|
27
|
+
include_test_location_in_result?(event: unknown, state: unknown): void | Promise<void>;
|
28
|
+
hook_start?(event: unknown, state: unknown): void | Promise<void>;
|
29
|
+
hook_success?(event: unknown, state: unknown): void | Promise<void>;
|
30
|
+
hook_failure?(event: unknown, state: unknown): void | Promise<void>;
|
31
|
+
test_fn_start?(event: unknown, state: unknown): void | Promise<void>;
|
32
|
+
test_fn_success?(event: unknown, state: unknown): void | Promise<void>;
|
33
|
+
test_fn_failure?(event: unknown, state: unknown): void | Promise<void>;
|
34
|
+
test_retry?(event: unknown, state: unknown): void | Promise<void>;
|
35
|
+
test_start?(event: unknown, state: unknown): void | Promise<void>;
|
36
|
+
test_skip?(event: unknown, state: unknown): void | Promise<void>;
|
37
|
+
test_todo?(event: unknown, state: unknown): void | Promise<void>;
|
38
|
+
test_done?(event: unknown, state: unknown): void | Promise<void>;
|
39
|
+
run_describe_start?(event: unknown, state: unknown): void | Promise<void>;
|
40
|
+
run_describe_finish?(event: unknown, state: unknown): void | Promise<void>;
|
41
|
+
run_start?(event: unknown, state: unknown): void | Promise<void>;
|
42
|
+
run_finish?(event: unknown, state: unknown): void | Promise<void>;
|
43
|
+
teardown?(event: unknown, state: unknown): void | Promise<void>;
|
44
|
+
}
|
45
|
+
|
46
|
+
export interface DetoxListenerFactory {
|
47
|
+
new (opts: DetoxCircusListenerConstructorOpts): DetoxCircusListener;
|
48
|
+
}
|
49
|
+
|
50
|
+
export class DetoxCircusEnvironment extends NodeEnvironment {
|
51
|
+
public readonly handleTestEvent: (event: unknown, state: unknown) => void | Promise<void>;
|
52
|
+
public readonly testPath: string;
|
53
|
+
|
54
|
+
protected registerListeners(map: Record<string, DetoxListenerFactory>): void;
|
55
|
+
protected setupTimeout: number;
|
56
|
+
protected teardownTimeout: number;
|
57
|
+
protected initDetox(): Promise<DetoxInternals.Worker>;
|
58
|
+
protected cleanupDetox(): Promise<void>;
|
59
|
+
}
|
60
|
+
}
|
package/runners/jest/index.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
// Lazy require() is used to avoid initializing a bare Detox context when it is not needed.
|
2
|
+
// At the moment, this safety measure is not really needed, but it's better to be on the safe side.
|
3
3
|
|
4
|
+
module.exports = {
|
4
5
|
get DetoxCircusEnvironment() {
|
5
6
|
return require('./testEnvironment');
|
6
7
|
},
|
7
8
|
|
8
|
-
//#endregion
|
9
|
-
|
10
|
-
//#region *** Worker Realm ***
|
11
|
-
|
12
9
|
get globalSetup() {
|
13
10
|
return require('./globalSetup');
|
14
11
|
},
|
@@ -16,6 +13,4 @@ module.exports = {
|
|
16
13
|
get globalTeardown() {
|
17
14
|
return require('./globalTeardown');
|
18
15
|
},
|
19
|
-
|
20
|
-
//#endregion
|
21
16
|
};
|
@@ -5,20 +5,31 @@ const JestVerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters'
|
|
5
5
|
const { config, reportTestResults } = require('../../../internals');
|
6
6
|
|
7
7
|
class DetoxReporter extends JestVerboseReporter {
|
8
|
+
/**
|
9
|
+
* @param {import('@jest/test-result').AggregatedResult} results
|
10
|
+
*/
|
11
|
+
// @ts-ignore
|
12
|
+
async onRunComplete(_contexts, results) {
|
13
|
+
// @ts-ignore
|
14
|
+
await super.onRunComplete(_contexts, results);
|
15
|
+
|
16
|
+
await reportTestResults(results.testResults.map(r => ({
|
17
|
+
success: !r.failureMessage,
|
18
|
+
testFilePath: r.testFilePath,
|
19
|
+
testExecError: r.testExecError,
|
20
|
+
isPermanentFailure: this._isPermanentFailure(r),
|
21
|
+
})));
|
22
|
+
}
|
23
|
+
|
8
24
|
/**
|
9
25
|
* @param {import('@jest/test-result').TestResult} testResult
|
10
26
|
*/
|
11
|
-
|
12
|
-
|
27
|
+
_isPermanentFailure(testResult) {
|
28
|
+
if (config.testRunner.jest.retryAfterCircusRetries) {
|
29
|
+
return false;
|
30
|
+
}
|
13
31
|
|
14
|
-
|
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.status === 'failed' && r.invocations > 1)
|
21
|
-
}]);
|
32
|
+
return testResult.testResults.some(r => r.status === 'failed' && r.invocations > 1);
|
22
33
|
}
|
23
34
|
}
|
24
35
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
1
3
|
const resolveFrom = require('resolve-from');
|
2
4
|
const maybeNodeEnvironment = require(resolveFrom(process.cwd(), 'jest-environment-node'));
|
3
5
|
/** @type {typeof import('@jest/environment').JestEnvironment} */
|
@@ -39,7 +41,7 @@ class DetoxCircusEnvironment extends NodeEnvironment {
|
|
39
41
|
this._timer = new Timer();
|
40
42
|
|
41
43
|
/** @internal */
|
42
|
-
this.testPath = context.testPath;
|
44
|
+
this.testPath = path.relative(process.cwd(), context.testPath);
|
43
45
|
/** @protected */
|
44
46
|
this.testEventListeners = [];
|
45
47
|
/** @protected */
|
@@ -49,45 +51,8 @@ class DetoxCircusEnvironment extends NodeEnvironment {
|
|
49
51
|
|
50
52
|
log.trace.begin(this.testPath);
|
51
53
|
|
52
|
-
|
53
|
-
this.
|
54
|
-
await log.trace.complete('set up environment', async () => {
|
55
|
-
try {
|
56
|
-
this._timer.schedule(this.setupTimeout);
|
57
|
-
await this._handleTestEventAsync({ name: 'environment_setup_start' });
|
58
|
-
await this._timer.run(`setting up Detox environment`, _setup);
|
59
|
-
await this._handleTestEventAsync({ name: 'environment_setup_success' });
|
60
|
-
} catch (error) {
|
61
|
-
this._timer.schedule(this.teardownTimeout);
|
62
|
-
await this._handleTestEventAsync({ name: 'environment_setup_failure', error });
|
63
|
-
throw error;
|
64
|
-
} finally {
|
65
|
-
this._timer.clear();
|
66
|
-
}
|
67
|
-
});
|
68
|
-
};
|
69
|
-
|
70
|
-
const _teardown = this.teardown.bind(this);
|
71
|
-
this.teardown = async () => {
|
72
|
-
await log.trace.complete('tear down environment', async () => {
|
73
|
-
try {
|
74
|
-
this._timer.schedule(this.teardownTimeout);
|
75
|
-
await this._handleTestEventAsync({ name: 'environment_teardown_start' });
|
76
|
-
await this._timer.run(`tearing down Detox environment`, _teardown);
|
77
|
-
await this._handleTestEventAsync({ name: 'environment_teardown_success' });
|
78
|
-
} catch (error) {
|
79
|
-
if (this._timer.expired) {
|
80
|
-
this._timer.schedule(this.teardownTimeout);
|
81
|
-
}
|
82
|
-
|
83
|
-
await this._handleTestEventAsync({ name: 'environment_teardown_failure', error });
|
84
|
-
throw error;
|
85
|
-
} finally {
|
86
|
-
this._timer.clear();
|
87
|
-
log.trace.end();
|
88
|
-
}
|
89
|
-
});
|
90
|
-
};
|
54
|
+
this.setup = this._wrapSetup(this.setup);
|
55
|
+
this.teardown = this._wrapTeardown(this.teardown);
|
91
56
|
|
92
57
|
this.registerListeners({
|
93
58
|
DetoxInitErrorListener,
|
@@ -100,6 +65,7 @@ class DetoxCircusEnvironment extends NodeEnvironment {
|
|
100
65
|
|
101
66
|
/** @override */
|
102
67
|
async setup() {
|
68
|
+
await super.setup();
|
103
69
|
await this.initDetox();
|
104
70
|
}
|
105
71
|
|
@@ -115,7 +81,11 @@ class DetoxCircusEnvironment extends NodeEnvironment {
|
|
115
81
|
|
116
82
|
/** @override */
|
117
83
|
async teardown() {
|
118
|
-
|
84
|
+
try {
|
85
|
+
await this.cleanupDetox();
|
86
|
+
} finally {
|
87
|
+
await super.teardown();
|
88
|
+
}
|
119
89
|
}
|
120
90
|
|
121
91
|
/** @protected */
|
@@ -184,6 +154,52 @@ class DetoxCircusEnvironment extends NodeEnvironment {
|
|
184
154
|
}
|
185
155
|
}
|
186
156
|
}
|
157
|
+
|
158
|
+
_wrapSetup(fn) {
|
159
|
+
const _setup = fn.bind(this);
|
160
|
+
|
161
|
+
return async () => {
|
162
|
+
await log.trace.complete('set up environment', async () => {
|
163
|
+
try {
|
164
|
+
this._timer.schedule(this.setupTimeout);
|
165
|
+
await this._handleTestEventAsync({ name: 'environment_setup_start' });
|
166
|
+
await this._timer.run(`setting up Detox environment`, _setup);
|
167
|
+
await this._handleTestEventAsync({ name: 'environment_setup_success' });
|
168
|
+
} catch (error) {
|
169
|
+
this._timer.schedule(this.teardownTimeout);
|
170
|
+
await this._handleTestEventAsync({ name: 'environment_setup_failure', error });
|
171
|
+
throw error;
|
172
|
+
} finally {
|
173
|
+
this._timer.clear();
|
174
|
+
}
|
175
|
+
});
|
176
|
+
};
|
177
|
+
}
|
178
|
+
|
179
|
+
_wrapTeardown(fn) {
|
180
|
+
const _teardown = fn.bind(this);
|
181
|
+
|
182
|
+
return async () => {
|
183
|
+
await log.trace.complete('tear down environment', async () => {
|
184
|
+
try {
|
185
|
+
this._timer.schedule(this.teardownTimeout);
|
186
|
+
await this._handleTestEventAsync({ name: 'environment_teardown_start' });
|
187
|
+
await this._timer.run(`tearing down Detox environment`, _teardown);
|
188
|
+
await this._handleTestEventAsync({ name: 'environment_teardown_success' });
|
189
|
+
} catch (error) {
|
190
|
+
if (this._timer.expired) {
|
191
|
+
this._timer.schedule(this.teardownTimeout);
|
192
|
+
}
|
193
|
+
|
194
|
+
await this._handleTestEventAsync({ name: 'environment_teardown_failure', error });
|
195
|
+
throw error;
|
196
|
+
} finally {
|
197
|
+
this._timer.clear();
|
198
|
+
log.trace.end();
|
199
|
+
}
|
200
|
+
});
|
201
|
+
};
|
202
|
+
}
|
187
203
|
}
|
188
204
|
|
189
205
|
module.exports = DetoxCircusEnvironment;
|
@@ -11,8 +11,8 @@ const log = detoxInternals.log.child({ cat: 'lifecycle,jest-environment' });
|
|
11
11
|
|
12
12
|
class DetoxCoreListener {
|
13
13
|
constructor({ env }) {
|
14
|
-
this._startedTests = new
|
15
|
-
this._testsFailedBeforeStart = new
|
14
|
+
this._startedTests = new Set();
|
15
|
+
this._testsFailedBeforeStart = new Set();
|
16
16
|
this._env = env;
|
17
17
|
this._circusRetryTimes = 1;
|
18
18
|
}
|
@@ -41,10 +41,22 @@ class DetoxCoreListener {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
async test_start({ test }) {
|
44
|
-
|
44
|
+
const metadata = this._getTestMetadata(test);
|
45
|
+
if (metadata.status === 'failed') {
|
45
46
|
this._testsFailedBeforeStart.add(test);
|
46
47
|
}
|
47
48
|
|
49
|
+
const logTrace = this._isTestSkipped(test)
|
50
|
+
? log.trace
|
51
|
+
: log.trace.begin;
|
52
|
+
|
53
|
+
logTrace({
|
54
|
+
context: 'test',
|
55
|
+
status: metadata.status,
|
56
|
+
fullName: metadata.fullName,
|
57
|
+
invocations: metadata.invocations,
|
58
|
+
}, metadata.title);
|
59
|
+
|
48
60
|
const circusRetryTimes = +this._env.global[RETRY_TIMES];
|
49
61
|
this._circusRetryTimes = isNaN(circusRetryTimes) ? 1 : 1 + circusRetryTimes;
|
50
62
|
}
|
@@ -69,7 +81,11 @@ class DetoxCoreListener {
|
|
69
81
|
|
70
82
|
async test_fn_start({ test }) {
|
71
83
|
await this._onBeforeActualTestStart(test);
|
72
|
-
|
84
|
+
|
85
|
+
if (!this._testsFailedBeforeStart.has(test)) {
|
86
|
+
// Jest bug workaround: beforeAll hook errors result into an unterminated test_fn_start event.
|
87
|
+
log.trace.begin({ functionCode: test.fn.toString() }, 'test_fn');
|
88
|
+
}
|
73
89
|
}
|
74
90
|
|
75
91
|
async test_fn_success() {
|
@@ -82,57 +98,68 @@ class DetoxCoreListener {
|
|
82
98
|
}
|
83
99
|
|
84
100
|
async test_done({ test }) {
|
85
|
-
|
86
|
-
const failed = test.errors.length > 0;
|
87
|
-
const metadata = {
|
88
|
-
...this._getTestMetadata(test),
|
89
|
-
status: failed ? 'failed' : 'passed',
|
90
|
-
timedOut: failed ? hasTimedOut(test) : undefined,
|
91
|
-
};
|
101
|
+
const metadata = this._getTestMetadata(test);
|
92
102
|
|
103
|
+
if (this._startedTests.has(test)) {
|
93
104
|
await detoxInternals.onTestDone(metadata);
|
94
105
|
this._startedTests.delete(test);
|
95
|
-
log.trace.end({
|
96
|
-
status: metadata.status,
|
97
|
-
timedOut: metadata.timedOut,
|
98
|
-
});
|
99
106
|
}
|
107
|
+
|
108
|
+
log.trace.end(_.pick(metadata, ['status', 'timedOut']));
|
100
109
|
}
|
101
110
|
|
102
111
|
async _onBeforeActualTestStart(test) {
|
103
|
-
if (!
|
104
|
-
return
|
112
|
+
if (!this._isTestActuallyStarting(test)) {
|
113
|
+
return;
|
105
114
|
}
|
106
115
|
|
107
|
-
const metadata = {
|
108
|
-
...this._getTestMetadata(test),
|
109
|
-
status: 'running',
|
110
|
-
};
|
111
|
-
|
112
116
|
this._startedTests.add(test);
|
117
|
+
await detoxInternals.onTestStart(this._getTestMetadata(test));
|
118
|
+
}
|
113
119
|
|
114
|
-
|
115
|
-
|
116
|
-
status: metadata.status,
|
117
|
-
fullName: metadata.fullName,
|
118
|
-
invocations: metadata.invocations,
|
119
|
-
}, metadata.title);
|
120
|
-
|
121
|
-
await detoxInternals.onTestStart(metadata);
|
122
|
-
return true;
|
120
|
+
_isTestActuallyStarting(test) {
|
121
|
+
return test && !this._isTestSkipped(test) && !this._startedTests.has(test) && !this._testsFailedBeforeStart.has(test);
|
123
122
|
}
|
124
123
|
|
125
|
-
|
126
|
-
|
127
|
-
return testSessionIndex * this._circusRetryTimes + test.invocations;
|
124
|
+
_isTestSkipped(test) {
|
125
|
+
return test && (test.mode === 'skip' || test.mode === 'todo');
|
128
126
|
}
|
129
127
|
|
130
128
|
_getTestMetadata(test) {
|
131
|
-
|
129
|
+
const result = {
|
132
130
|
title: test.name,
|
133
131
|
fullName: getFullTestName(test),
|
132
|
+
status: this._getTestStatus(test),
|
134
133
|
invocations: this._getTestInvocations(test),
|
135
134
|
};
|
135
|
+
|
136
|
+
if (result.status === 'failed') {
|
137
|
+
result.timedOut = hasTimedOut(test);
|
138
|
+
}
|
139
|
+
|
140
|
+
return result;
|
141
|
+
}
|
142
|
+
|
143
|
+
/** @returns { 'failed' | 'passed' | 'running' | 'skip' | 'todo' } */
|
144
|
+
_getTestStatus(test) {
|
145
|
+
if (!_.isEmpty(test.errors)) {
|
146
|
+
return 'failed';
|
147
|
+
}
|
148
|
+
|
149
|
+
if (this._isTestSkipped(test)) {
|
150
|
+
return test.mode;
|
151
|
+
}
|
152
|
+
|
153
|
+
if (test.status === 'done') {
|
154
|
+
return 'passed';
|
155
|
+
} else {
|
156
|
+
return test.status || 'running';
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
_getTestInvocations(test) {
|
161
|
+
const { testSessionIndex } = detoxInternals.session;
|
162
|
+
return testSessionIndex * this._circusRetryTimes + test.invocations;
|
136
163
|
}
|
137
164
|
}
|
138
165
|
|