detox 19.13.0 → 20.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-javadoc.jar → 20.0.0/detox-20.0.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-sources.jar → 20.0.0/detox-20.0.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0.pom → 20.0.0/detox-20.0.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.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/README.md +1 -1
- package/android/detox/src/full/java/com/wix/detox/Detox.java +2 -59
- package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
- package/index.d.ts +354 -191
- package/index.js +1 -0
- package/internals.d.ts +298 -0
- package/internals.js +4 -0
- package/local-cli/build-framework-cache.js +2 -2
- package/local-cli/build.js +7 -8
- package/local-cli/build.test.js +46 -40
- package/local-cli/clean-framework-cache.js +3 -3
- package/local-cli/cli.js +8 -7
- package/local-cli/init.js +73 -68
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +14 -36
- package/local-cli/test.js +24 -282
- package/local-cli/test.test.js +394 -648
- package/local-cli/testCommand/TestRunnerCommand.js +163 -0
- package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -36
- package/local-cli/testCommand/middlewares.js +66 -0
- package/local-cli/{utils → testCommand}/warnings.js +0 -13
- package/local-cli/utils/jestInternals.js +13 -2
- package/local-cli/utils/yargsUtils.js +67 -0
- package/package.json +32 -19
- package/runners/deprecation.js +45 -0
- package/runners/jest/JestCircusEnvironment.js +3 -38
- package/runners/jest/adapter.d.ts +4 -10
- package/runners/jest/adapter.js +3 -6
- package/runners/jest/assignReporter.d.ts +4 -1
- package/runners/jest/assignReporter.js +3 -6
- package/runners/jest/globalSetup.js +1 -0
- package/runners/jest/globalTeardown.js +1 -0
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +16 -0
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporter.js +1 -0
- package/runners/jest/reporters/DetoxReporter.js +36 -0
- package/runners/jest/specReporter.d.ts +4 -9
- package/runners/jest/specReporter.js +3 -10
- package/runners/jest/streamlineReporter.js +3 -22
- package/runners/jest/testEnvironment/index.js +205 -0
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +166 -0
- package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
- package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -9
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +30 -0
- package/runners/jest/testEnvironment/listeners/index.js +13 -0
- package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +70 -0
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +22 -0
- package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
- package/runners/jest-circus/environment/index.js +6 -0
- package/runners/jest-circus/index.js +1 -10
- package/runners/jest-circus/reporter.js +1 -0
- package/runners/migration.js +37 -0
- package/runners/mocha/DetoxMochaAdapter.js +3 -35
- package/runners/mocha/adapter.d.ts +4 -7
- package/runners/mocha/adapter.js +3 -5
- package/src/DetoxWorker.js +327 -0
- package/src/android/interactions/native.js +2 -1
- package/src/artifacts/ArtifactsManager.js +51 -35
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/providers/index.js +0 -4
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
- package/src/artifacts/utils/temporaryPath.js +18 -5
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +1 -1
- package/src/client/actions/actions.js +2 -2
- package/src/configuration/collectCliConfig.js +3 -16
- package/src/configuration/composeAppsConfig.js +12 -66
- package/src/configuration/composeArtifactsConfig.js +6 -32
- package/src/configuration/composeBehaviorConfig.js +3 -13
- package/src/configuration/composeDeviceConfig.js +38 -63
- package/src/configuration/composeLoggerConfig.js +59 -0
- package/src/configuration/composeRunnerConfig.js +127 -14
- package/src/configuration/composeSessionConfig.js +1 -3
- package/src/configuration/index.js +36 -30
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/configuration/utils/deviceAppTypes.js +0 -1
- package/src/devices/allocation/DeviceAllocator.js +4 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +5 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
- package/src/devices/allocation/factories/index.js +0 -1
- package/src/devices/common/drivers/DeviceLauncher.js +2 -2
- package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
- package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +35 -10
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +85 -86
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +3 -3
- package/src/devices/runtime/drivers/index.js +0 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +4 -3
- package/src/devices/runtime/factories/ios.js +1 -8
- package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
- package/src/devices/runtime/utils/Storage.js +4 -0
- package/src/environmentFactory.js +0 -8
- package/src/errors/DetoxConfigErrorComposer.js +92 -30
- package/src/errors/DetoxError.js +4 -0
- package/src/errors/DetoxRuntimeError.js +5 -5
- package/src/errors/index.js +2 -0
- package/src/ios/expectTwo.js +2 -1
- package/src/ipc/IPCClient.js +117 -0
- package/src/ipc/IPCServer.js +98 -0
- package/src/ipc/SessionState.js +62 -0
- package/src/logger/DetoxLogger.js +348 -0
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +76 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
- package/src/logger/utils/DetoxLogFinalizer.js +140 -0
- package/src/logger/utils/MessageStack.js +24 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/{utils → logger/utils}/customConsoleLogger.js +5 -4
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streamUtils.js +248 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxConstants.js +13 -0
- package/src/realms/DetoxContext.js +183 -0
- package/src/realms/DetoxInternalsFacade.js +31 -0
- package/src/realms/DetoxPrimaryContext.js +261 -0
- package/src/realms/DetoxSecondaryContext.js +91 -0
- package/src/realms/index.js +10 -0
- package/src/realms/primary.js +3 -0
- package/src/realms/secondary.js +3 -0
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +50 -0
- package/src/utils/Timer.js +58 -33
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
- package/src/utils/errorUtils.js +20 -0
- package/src/utils/logger.js +2 -162
- package/src/utils/shellUtils.js +18 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha512 +0 -1
- package/local-cli/templates/mocha.js +0 -32
- package/local-cli/utils/splitArgv.js +0 -107
- package/runners/integration.js +0 -16
- package/runners/jest/DetoxAdapterCircus.js +0 -60
- package/runners/jest/DetoxAdapterImpl.js +0 -81
- package/runners/jest/DetoxAdapterJasmine.js +0 -67
- package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
- package/runners/jest/FailingTestsReporter.js +0 -16
- package/runners/jest/SpecReporterCircus.js +0 -51
- package/runners/jest/SpecReporterJasmine.js +0 -39
- package/runners/jest/WorkerAssignReporterCircus.js +0 -17
- package/runners/jest/WorkerAssignReporterImpl.js +0 -21
- package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
- package/runners/jest/runnerInfo.js +0 -9
- package/runners/jest-circus/environment.js +0 -206
- package/runners/jest-circus/listeners/DetoxCoreListener.js +0 -113
- package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
- package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
- package/src/Detox.js +0 -317
- package/src/DetoxConstants.js +0 -13
- package/src/DetoxExportWrapper.js +0 -140
- package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -92
- package/src/configuration/utils/warnings.js +0 -12
- package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
- package/src/devices/allocation/factories/none.js +0 -11
- package/src/index.js +0 -6
- package/src/utils/ChromeTracingExporter.js +0 -54
- package/src/utils/MissingDetox.js +0 -78
- package/src/utils/fakeTimestampsProvider.js +0 -9
- package/src/utils/getWorkerId.js +0 -5
- package/src/utils/lastFailedTests.js +0 -38
- package/src/utils/sh.js +0 -18
- package/src/utils/trace.js +0 -96
@@ -1,38 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
/**
|
6
|
-
* @see https://www.npmjs.com/package/jest-circus#overview
|
7
|
-
*/
|
8
|
-
class JestCircusEnvironment extends NodeEnvironment {
|
9
|
-
constructor(config) {
|
10
|
-
super(config);
|
11
|
-
this.testEventListeners = [];
|
12
|
-
|
13
|
-
// Enable access to this instance (single in each worker's scope) by exposing a get-function.
|
14
|
-
// Note: whatever's set into this.global will be exported in that way. The reason behind it is that
|
15
|
-
// each suite is run inside a sandboxed JS context which scope is in fact this specific instance. See
|
16
|
-
// NodeEnvironment's constructor for more info, or https://jestjs.io/docs/en/configuration#testenvironment-string
|
17
|
-
// for additional ref.
|
18
|
-
this.global.detoxCircus = {
|
19
|
-
getEnv: () => this,
|
20
|
-
};
|
21
|
-
}
|
22
|
-
|
23
|
-
addEventsListener(listener) {
|
24
|
-
this.testEventListeners.push(listener);
|
25
|
-
}
|
26
|
-
|
27
|
-
async handleTestEvent(event, state) {
|
28
|
-
const name = event.name;
|
29
|
-
|
30
|
-
for (const listener of this.testEventListeners) {
|
31
|
-
if (typeof listener[name] === 'function') {
|
32
|
-
await listener[name](event, state);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
module.exports = JestCircusEnvironment;
|
1
|
+
/** @deprecated */
|
2
|
+
/** @type {never} */
|
3
|
+
module.exports = require('../deprecation');
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
// These are not publicly used, but are defined in order to overlap with the jasmine.CustomReporter interface (which is a weak interface)
|
6
|
-
specDone: () => void;
|
7
|
-
specStarted: () => void;
|
8
|
-
}
|
9
|
-
|
10
|
-
declare const adapter: DetoxJestAdapter;
|
1
|
+
/***
|
2
|
+
* @deprecated Detox does not support old Jest integrations since v20.0.0
|
3
|
+
*/
|
4
|
+
declare const adapter: never;
|
11
5
|
|
12
6
|
export = adapter;
|
package/runners/jest/adapter.js
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const DetoxAdapter = runnerInfo.isJestCircus ? require('./DetoxAdapterCircus') : require('./DetoxAdapterJasmine');
|
5
|
-
|
6
|
-
module.exports = new DetoxAdapter(detox);
|
1
|
+
/** @deprecated */
|
2
|
+
/** @type {never} */
|
3
|
+
module.exports = require('../deprecation');
|
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const Reporter = runnerInfo.isJestCircus ? require('./WorkerAssignReporterCircus') : require('./WorkerAssignReporterJasmine');
|
6
|
-
module.exports = new Reporter({ detox });
|
1
|
+
/** @deprecated */
|
2
|
+
/** @type {never} */
|
3
|
+
module.exports = require('../deprecation');
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = async () => require('../../internals').init({ workerId: null });
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = async () => require('../../internals').cleanup();
|
@@ -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
|
+
}
|
@@ -0,0 +1,16 @@
|
|
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
|
+
|
4
|
+
module.exports = {
|
5
|
+
get DetoxCircusEnvironment() {
|
6
|
+
return require('./testEnvironment');
|
7
|
+
},
|
8
|
+
|
9
|
+
get globalSetup() {
|
10
|
+
return require('./globalSetup');
|
11
|
+
},
|
12
|
+
|
13
|
+
get globalTeardown() {
|
14
|
+
return require('./globalTeardown');
|
15
|
+
},
|
16
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
describe('detox/runners/jest', () => {
|
2
|
+
it('should lazily require the exported modules', () => {
|
3
|
+
const index = require('./index');
|
4
|
+
|
5
|
+
jest.mock('./testEnvironment', () => 0);
|
6
|
+
jest.mock('./globalSetup', () => 1);
|
7
|
+
jest.mock('./globalTeardown', () => 2);
|
8
|
+
|
9
|
+
expect(index.DetoxCircusEnvironment).toBe(0);
|
10
|
+
expect(index.globalSetup).toBe(1);
|
11
|
+
expect(index.globalTeardown).toBe(2);
|
12
|
+
});
|
13
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./reporters/DetoxReporter');
|
@@ -0,0 +1,36 @@
|
|
1
|
+
const resolveFrom = require('resolve-from');
|
2
|
+
/** @type {typeof import('@jest/reporters').VerboseReporter} */
|
3
|
+
const JestVerboseReporter = require(resolveFrom(process.cwd(), '@jest/reporters')).VerboseReporter;
|
4
|
+
|
5
|
+
const { config, reportTestResults } = require('../../../internals');
|
6
|
+
|
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
|
+
|
24
|
+
/**
|
25
|
+
* @param {import('@jest/test-result').TestResult} testResult
|
26
|
+
*/
|
27
|
+
_isPermanentFailure(testResult) {
|
28
|
+
if (config.testRunner.jest.retryAfterCircusRetries) {
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
|
32
|
+
return testResult.testResults.some(r => r.status === 'failed' && r.invocations > 1);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
module.exports = DetoxReporter;
|
@@ -1,11 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
specDone: () => void;
|
6
|
-
specStarted: () => void;
|
7
|
-
}
|
8
|
-
|
9
|
-
declare const specReporter: SpecReporter;
|
1
|
+
/***
|
2
|
+
* @deprecated Detox does not support old Jest integrations since v20.0.0
|
3
|
+
*/
|
4
|
+
declare const specReporter: never;
|
10
5
|
|
11
6
|
export = specReporter;
|
@@ -1,10 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
if (argparse.getArgValue('reportSpecs') === 'true') {
|
6
|
-
const Reporter = runnerInfo.isJestCircus ? require('./SpecReporterCircus') : require('./SpecReporterJasmine');
|
7
|
-
module.exports = new Reporter();
|
8
|
-
} else {
|
9
|
-
module.exports = {};
|
10
|
-
}
|
1
|
+
/** @deprecated */
|
2
|
+
/** @type {never} */
|
3
|
+
module.exports = require('../deprecation');
|
@@ -1,22 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
* TODO: rename this file to reporter.js in the next major version (Detox 18)
|
5
|
-
*/
|
6
|
-
|
7
|
-
const DetoxStreamlineJestReporter = require('./DetoxStreamlineJestReporter');
|
8
|
-
const FailingTestsReporter = require('./FailingTestsReporter');
|
9
|
-
|
10
|
-
class DetoxReporter extends DetoxStreamlineJestReporter {
|
11
|
-
constructor(globalConfig) {
|
12
|
-
super(globalConfig);
|
13
|
-
this._failingTestsReporter = new FailingTestsReporter();
|
14
|
-
}
|
15
|
-
|
16
|
-
async onRunComplete(contexts, results) {
|
17
|
-
await super.onRunComplete(contexts, results);
|
18
|
-
await this._failingTestsReporter.onRunComplete(contexts, results);
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
module.exports = DetoxReporter;
|
1
|
+
/** @deprecated */
|
2
|
+
/** @type {never} */
|
3
|
+
module.exports = require('../deprecation');
|
@@ -0,0 +1,205 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
const resolveFrom = require('resolve-from');
|
4
|
+
const maybeNodeEnvironment = require(resolveFrom(process.cwd(), 'jest-environment-node'));
|
5
|
+
/** @type {typeof import('@jest/environment').JestEnvironment} */
|
6
|
+
const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;
|
7
|
+
|
8
|
+
const detox = require('../../../internals');
|
9
|
+
const Timer = require('../../../src/utils/Timer');
|
10
|
+
|
11
|
+
const {
|
12
|
+
DetoxCoreListener,
|
13
|
+
DetoxInitErrorListener,
|
14
|
+
DetoxPlatformFilterListener,
|
15
|
+
SpecReporter,
|
16
|
+
WorkerAssignReporter
|
17
|
+
} = require('./listeners');
|
18
|
+
const assertExistingContext = require('./utils/assertExistingContext');
|
19
|
+
const { assertJestCircus27 } = require('./utils/assertJestCircus27');
|
20
|
+
|
21
|
+
const SYNC_CIRCUS_EVENTS = new Set([
|
22
|
+
'start_describe_definition',
|
23
|
+
'finish_describe_definition',
|
24
|
+
'add_hook',
|
25
|
+
'add_test',
|
26
|
+
'error',
|
27
|
+
]);
|
28
|
+
|
29
|
+
const log = detox.log.child({ cat: 'lifecycle,jest-environment' });
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @see https://www.npmjs.com/package/jest-circus#overview
|
33
|
+
*/
|
34
|
+
class DetoxCircusEnvironment extends NodeEnvironment {
|
35
|
+
constructor(config, context) {
|
36
|
+
super(assertJestCircus27(config), assertExistingContext(context));
|
37
|
+
|
38
|
+
/** @private */
|
39
|
+
this._shouldManageDetox = detox.getStatus() === 'inactive';
|
40
|
+
/** @private */
|
41
|
+
this._timer = new Timer();
|
42
|
+
|
43
|
+
/** @internal */
|
44
|
+
this.testPath = path.relative(process.cwd(), context.testPath);
|
45
|
+
/** @protected */
|
46
|
+
this.testEventListeners = [];
|
47
|
+
/** @protected */
|
48
|
+
this.setupTimeout = detox.config.testRunner.jest.setupTimeout;
|
49
|
+
/** @protected */
|
50
|
+
this.teardownTimeout = detox.config.testRunner.jest.teardownTimeout;
|
51
|
+
|
52
|
+
log.trace.begin(this.testPath);
|
53
|
+
|
54
|
+
this.setup = this._wrapSetup(this.setup);
|
55
|
+
this.teardown = this._wrapTeardown(this.teardown);
|
56
|
+
|
57
|
+
this.registerListeners({
|
58
|
+
DetoxInitErrorListener,
|
59
|
+
DetoxPlatformFilterListener,
|
60
|
+
DetoxCoreListener,
|
61
|
+
SpecReporter,
|
62
|
+
WorkerAssignReporter,
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
/** @override */
|
67
|
+
async setup() {
|
68
|
+
await super.setup();
|
69
|
+
await this.initDetox();
|
70
|
+
}
|
71
|
+
|
72
|
+
handleTestEvent = async (event, state) => {
|
73
|
+
this._timer.schedule(state.testTimeout != null ? state.testTimeout : this.setupTimeout);
|
74
|
+
|
75
|
+
if (SYNC_CIRCUS_EVENTS.has(event.name)) {
|
76
|
+
this._handleTestEventSync(event, state);
|
77
|
+
} else {
|
78
|
+
await this._handleTestEventAsync(event, state);
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
/** @override */
|
83
|
+
async teardown() {
|
84
|
+
try {
|
85
|
+
await this.cleanupDetox();
|
86
|
+
} finally {
|
87
|
+
await super.teardown();
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
/** @protected */
|
92
|
+
registerListeners(map) {
|
93
|
+
for (const Listener of Object.values(map)) {
|
94
|
+
this.testEventListeners.push(new Listener({
|
95
|
+
env: this,
|
96
|
+
}));
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* @protected
|
102
|
+
*/
|
103
|
+
async initDetox() {
|
104
|
+
const opts = {
|
105
|
+
global: this.global,
|
106
|
+
workerId: `w${process.env.JEST_WORKER_ID}`,
|
107
|
+
};
|
108
|
+
|
109
|
+
if (this._shouldManageDetox) {
|
110
|
+
await detox.init(opts);
|
111
|
+
} else {
|
112
|
+
await detox.installWorker(opts);
|
113
|
+
}
|
114
|
+
|
115
|
+
return detox.worker;
|
116
|
+
}
|
117
|
+
|
118
|
+
/** @protected */
|
119
|
+
async cleanupDetox() {
|
120
|
+
if (this._shouldManageDetox) {
|
121
|
+
await detox.cleanup();
|
122
|
+
} else {
|
123
|
+
await detox.uninstallWorker();
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
/** @private */
|
128
|
+
_handleTestEventSync(event, state) {
|
129
|
+
const { name } = event;
|
130
|
+
|
131
|
+
for (const listener of this.testEventListeners) {
|
132
|
+
if (typeof listener[name] === 'function') {
|
133
|
+
listener[name](event, state);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
/** @private */
|
139
|
+
async _handleTestEventAsync(event, state = null) {
|
140
|
+
const description = `handling ${state ? 'jest-circus' : 'jest-environment'} "${event.name}" event`;
|
141
|
+
|
142
|
+
for (const listener of this.testEventListeners) {
|
143
|
+
if (typeof listener[event.name] !== 'function') {
|
144
|
+
continue;
|
145
|
+
}
|
146
|
+
|
147
|
+
try {
|
148
|
+
await this._timer.run(description, () => listener[event.name](event, state));
|
149
|
+
} catch (listenerError) {
|
150
|
+
log.error(listenerError);
|
151
|
+
if (this._timer.expired) {
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
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
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
module.exports = DetoxCircusEnvironment;
|
@@ -0,0 +1,166 @@
|
|
1
|
+
// @ts-nocheck
|
2
|
+
const _ = require('lodash');
|
3
|
+
|
4
|
+
const detox = require('../../../..');
|
5
|
+
const detoxInternals = require('../../../../internals');
|
6
|
+
const { getFullTestName, hasTimedOut } = require('../utils');
|
7
|
+
|
8
|
+
const RETRY_TIMES = Symbol.for('RETRY_TIMES');
|
9
|
+
|
10
|
+
const log = detoxInternals.log.child({ cat: 'lifecycle,jest-environment' });
|
11
|
+
|
12
|
+
class DetoxCoreListener {
|
13
|
+
constructor({ env }) {
|
14
|
+
this._startedTests = new Set();
|
15
|
+
this._testsFailedBeforeStart = new Set();
|
16
|
+
this._env = env;
|
17
|
+
this._circusRetryTimes = 1;
|
18
|
+
}
|
19
|
+
|
20
|
+
async setup() {
|
21
|
+
// Workaround to override Jest's expect
|
22
|
+
if (detoxInternals.config.behavior.init.exposeGlobals) {
|
23
|
+
this._env.global.expect = detox.expect;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
async run_describe_start({ describeBlock }) {
|
28
|
+
if (describeBlock.children.length) {
|
29
|
+
log.trace.begin(describeBlock.parent ? describeBlock.name : 'run the tests');
|
30
|
+
await detoxInternals.onRunDescribeStart({
|
31
|
+
name: describeBlock.name,
|
32
|
+
});
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
async run_describe_finish({ describeBlock }) {
|
37
|
+
if (describeBlock.children.length) {
|
38
|
+
await detoxInternals.onRunDescribeFinish({ name: describeBlock.name });
|
39
|
+
log.trace.end();
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
async test_start({ test }) {
|
44
|
+
const metadata = this._getTestMetadata(test);
|
45
|
+
if (metadata.status === 'failed') {
|
46
|
+
this._testsFailedBeforeStart.add(test);
|
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
|
+
|
60
|
+
const circusRetryTimes = +this._env.global[RETRY_TIMES];
|
61
|
+
this._circusRetryTimes = isNaN(circusRetryTimes) ? 1 : 1 + circusRetryTimes;
|
62
|
+
}
|
63
|
+
|
64
|
+
async hook_start(event, state) {
|
65
|
+
await this._onBeforeActualTestStart(state.currentlyRunningTest);
|
66
|
+
log.trace.begin({ functionCode: event.hook.fn.toString() }, event.hook.type);
|
67
|
+
}
|
68
|
+
|
69
|
+
async hook_success() {
|
70
|
+
log.trace.end({ success: true });
|
71
|
+
}
|
72
|
+
|
73
|
+
async hook_failure({ error, hook }) {
|
74
|
+
await detoxInternals.onHookFailure({
|
75
|
+
error,
|
76
|
+
hook: hook.type,
|
77
|
+
});
|
78
|
+
|
79
|
+
log.trace.end({ success: false, error });
|
80
|
+
}
|
81
|
+
|
82
|
+
async test_fn_start({ test }) {
|
83
|
+
await this._onBeforeActualTestStart(test);
|
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
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
async test_fn_success() {
|
92
|
+
log.trace.end({ success: true });
|
93
|
+
}
|
94
|
+
|
95
|
+
async test_fn_failure({ error }) {
|
96
|
+
await detoxInternals.onTestFnFailure({ error });
|
97
|
+
log.trace.end({ success: false, error });
|
98
|
+
}
|
99
|
+
|
100
|
+
async test_done({ test }) {
|
101
|
+
const metadata = this._getTestMetadata(test);
|
102
|
+
|
103
|
+
if (this._startedTests.has(test)) {
|
104
|
+
await detoxInternals.onTestDone(metadata);
|
105
|
+
this._startedTests.delete(test);
|
106
|
+
}
|
107
|
+
|
108
|
+
log.trace.end(_.pick(metadata, ['status', 'timedOut']));
|
109
|
+
}
|
110
|
+
|
111
|
+
async _onBeforeActualTestStart(test) {
|
112
|
+
if (!this._isTestActuallyStarting(test)) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
|
116
|
+
this._startedTests.add(test);
|
117
|
+
await detoxInternals.onTestStart(this._getTestMetadata(test));
|
118
|
+
}
|
119
|
+
|
120
|
+
_isTestActuallyStarting(test) {
|
121
|
+
return test && !this._isTestSkipped(test) && !this._startedTests.has(test) && !this._testsFailedBeforeStart.has(test);
|
122
|
+
}
|
123
|
+
|
124
|
+
_isTestSkipped(test) {
|
125
|
+
return test && (test.mode === 'skip' || test.mode === 'todo');
|
126
|
+
}
|
127
|
+
|
128
|
+
_getTestMetadata(test) {
|
129
|
+
const result = {
|
130
|
+
title: test.name,
|
131
|
+
fullName: getFullTestName(test),
|
132
|
+
status: this._getTestStatus(test),
|
133
|
+
invocations: this._getTestInvocations(test),
|
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;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
module.exports = DetoxCoreListener;
|
@@ -15,7 +15,7 @@ class DetoxInitErrorListener {
|
|
15
15
|
if (!_.isEmpty(unhandledErrors)) {
|
16
16
|
const currentTest = _.last(currentDescribeBlock.children);
|
17
17
|
const dummyError = new Error('Environment setup failed. See the detailed error below.');
|
18
|
-
|
18
|
+
dummyError.stack = '';
|
19
19
|
|
20
20
|
currentTest.errors.push(dummyError);
|
21
21
|
}
|