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.
Files changed (144) hide show
  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 → 20.1.0/detox-20.1.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha512 +1 -0
  6. 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
  7. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha512 +1 -0
  16. 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
  17. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha512 +1 -0
  21. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  22. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  26. package/Detox-ios-src.tbz +0 -0
  27. package/Detox-ios.tbz +0 -0
  28. package/android/build.gradle +0 -1
  29. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
  30. package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
  31. package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
  32. package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
  33. package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
  34. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
  35. package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
  36. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
  37. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +2 -4
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
  39. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
  40. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
  41. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +1 -6
  42. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
  43. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
  44. package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
  45. package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
  46. package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
  47. package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
  48. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
  49. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
  50. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
  51. package/index.d.ts +102 -18
  52. package/internals.d.ts +34 -9
  53. package/local-cli/cli.js +6 -3
  54. package/local-cli/init.js +1 -1
  55. package/local-cli/test.js +6 -6
  56. package/local-cli/testCommand/TestRunnerCommand.js +97 -94
  57. package/local-cli/testCommand/TestRunnerError.js +17 -0
  58. package/local-cli/testCommand/builder.js +0 -1
  59. package/local-cli/testCommand/middlewares.js +4 -13
  60. package/local-cli/testCommand/warnings.js +0 -3
  61. package/package.json +18 -15
  62. package/runners/deprecation.js +42 -44
  63. package/runners/jest/index.d.ts +60 -0
  64. package/runners/jest/index.js +3 -8
  65. package/runners/jest/reporters/DetoxReporter.js +21 -10
  66. package/runners/jest/testEnvironment/index.js +57 -41
  67. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
  68. package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
  69. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
  70. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  71. package/src/DetoxWorker.js +95 -49
  72. package/src/android/interactions/native.js +3 -2
  73. package/src/artifacts/ArtifactsManager.js +6 -6
  74. package/src/artifacts/utils/temporaryPath.js +32 -2
  75. package/src/client/actions/SyncStatusSchema.json +21 -0
  76. package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
  77. package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
  78. package/src/configuration/collectCliConfig.js +1 -12
  79. package/src/configuration/composeRunnerConfig.js +5 -4
  80. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
  81. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
  82. package/src/devices/common/drivers/android/exec/ADB.js +4 -0
  83. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
  84. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +4 -0
  85. package/src/devices/runtime/RuntimeDevice.js +3 -3
  86. package/src/errors/DetoxConfigErrorComposer.js +6 -1
  87. package/src/errors/DetoxError.js +5 -1
  88. package/src/ios/expectTwo.js +3 -2
  89. package/src/ipc/IPCClient.js +26 -17
  90. package/src/ipc/IPCServer.js +11 -3
  91. package/src/ipc/SessionState.js +11 -11
  92. package/src/logger/DetoxLogger.js +63 -43
  93. package/src/logger/index.js +1 -0
  94. package/src/logger/utils/BunyanLogger.js +50 -7
  95. package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
  96. package/src/logger/utils/DetoxLogFinalizer.js +166 -0
  97. package/src/logger/utils/MessageStack.js +17 -6
  98. package/src/logger/utils/ThreadDispatcher.js +5 -25
  99. package/src/logger/utils/customConsoleLogger.js +22 -5
  100. package/src/logger/utils/getMainCategory.js +5 -0
  101. package/src/logger/utils/sanitizeBunyanContext.js +3 -1
  102. package/src/logger/utils/streams/BunyanTransformer.js +72 -0
  103. package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
  104. package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
  105. package/src/logger/utils/streams/JSONLStringer.js +55 -0
  106. package/src/logger/utils/streams/index.js +7 -0
  107. package/src/logger/utils/streams/transformers.js +39 -0
  108. package/src/logger/utils/tracerLegacy.js +14 -25
  109. package/src/realms/DetoxContext.js +11 -7
  110. package/src/realms/DetoxInternalsFacade.js +0 -6
  111. package/src/realms/DetoxPrimaryContext.js +42 -87
  112. package/src/realms/DetoxSecondaryContext.js +8 -12
  113. package/src/utils/argparse.js +11 -0
  114. package/src/utils/logger.js +1 -1
  115. package/src/utils/pathUtils.js +11 -0
  116. package/src/utils/shellUtils.js +17 -0
  117. package/src/utils/traceInvocationCall.js +21 -0
  118. 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
  119. 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
  120. 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
  121. 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
  122. 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
  123. 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
  124. 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
  125. 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
  126. 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
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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
  135. package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
  136. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
  137. package/local-cli/build.test.js +0 -104
  138. package/local-cli/run-server.test.js +0 -23
  139. package/local-cli/test.test.js +0 -569
  140. package/runners/jest/deprecation.js +0 -25
  141. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
  142. package/src/configuration/utils/warnings.js +0 -12
  143. package/src/logger/utils/streamUtils.js +0 -240
  144. package/src/utils/trace.js +0 -3
@@ -1,569 +0,0 @@
1
- // @ts-nocheck
2
- if (process.platform === 'win32') {
3
- jest.retryTimes(1); // TODO: investigate why it gets stuck for the 1st time on Windows
4
- }
5
-
6
- jest.mock('../src/logger/DetoxLogger');
7
- jest.mock('../src/devices/DeviceRegistry');
8
- jest.mock('../src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory');
9
- jest.mock('./utils/jestInternals');
10
-
11
- const cp = require('child_process');
12
- const cpSpawn = cp.spawn;
13
- const os = require('os');
14
- const path = require('path');
15
-
16
- const fs = require('fs-extra');
17
- const _ = require('lodash');
18
- const yargs = require('yargs');
19
-
20
- const { DEVICE_LAUNCH_ARGS_DEPRECATION } = require('./testCommand/warnings');
21
-
22
- describe('CLI', () => {
23
- let _cliCallDump;
24
- let _env;
25
- let logger;
26
- let _temporaryFiles;
27
- let detoxConfig;
28
- let detoxConfigPath;
29
- let DeviceRegistry;
30
- let GenyDeviceRegistryFactory;
31
- let jestInternals;
32
-
33
- afterEach(() => {
34
- cp.spawn = cpSpawn;
35
- });
36
-
37
- beforeEach(() => {
38
- _cliCallDump = undefined;
39
- _env = process.env;
40
- _temporaryFiles = [];
41
-
42
- process.env = {
43
- ..._env,
44
- CLI_TEST_STDOUT: tempfile('.txt'),
45
- };
46
-
47
- const executable = path.relative(process.cwd(), path.join(__dirname, '__mocks__/executable'));
48
-
49
- detoxConfig = {
50
- testRunner: {
51
- args: {
52
- $0: os.platform() === 'win32' ? `node ${executable}` : executable,
53
- config: 'e2e/config.json'
54
- },
55
- forwardEnv: true,
56
- },
57
- configurations: {
58
- single: {
59
- device: {
60
- type: 'ios.simulator',
61
- device: 'iPhone X'
62
- },
63
- apps: [],
64
- },
65
- },
66
- };
67
-
68
- const realJestInternals = jest.requireActual('./utils/jestInternals');
69
- jestInternals = require('./utils/jestInternals');
70
- Object.assign(jestInternals, realJestInternals);
71
- jestInternals.readJestConfig = jest.fn(async (argv) => {
72
- const runnerConfigTemplate = _.omit(
73
- JSON.parse(require('./templates/jest').runnerConfig),
74
- ['reporters', 'testEnvironment']
75
- );
76
-
77
- return realJestInternals.readJestConfig({
78
- ...argv,
79
- config: tempfile('.json', JSON.stringify(runnerConfigTemplate)),
80
- });
81
- });
82
-
83
- logger = () => require('../src/logger/DetoxLogger').instances[0];
84
- DeviceRegistry = require('../src/devices/DeviceRegistry');
85
- DeviceRegistry.forAndroid.mockImplementation(() => new DeviceRegistry());
86
- DeviceRegistry.forIOS.mockImplementation(() => new DeviceRegistry());
87
- GenyDeviceRegistryFactory = require('../src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory');
88
- GenyDeviceRegistryFactory.forGlobalShutdown.mockImplementation(() => new DeviceRegistry());
89
- });
90
-
91
- afterEach(async () => {
92
- process.env = _env;
93
-
94
- await Promise.all(_temporaryFiles.map(name => fs.remove(name)));
95
- });
96
-
97
- describe('by default', () => {
98
- test('by default, should attempt to load config from package.json or .detoxrc', async () => {
99
- const expectedError = /^Cannot run Detox without a configuration/;
100
- await expect(runRaw('test')).rejects.toThrowError(expectedError);
101
- });
102
- });
103
-
104
- describe.each([
105
- ['iOS', 'ios.simulator'],
106
- ['Android', 'android.emulator'],
107
- ])('given no extra args (%s)', (_platform, deviceType) => {
108
- beforeEach(async () => {
109
- singleConfig().device.type = deviceType;
110
- await run();
111
- });
112
-
113
- test('should produce a default command', () => {
114
- expect(cliCall().argv).toEqual([expect.stringContaining('executable'), '--config', 'e2e/config.json']);
115
- });
116
-
117
- test('should not override environment variables', () => {
118
- expect(cliCall().env).toEqual({
119
- DETOX_CONFIG_PATH: expect.any(String),
120
- DETOX_CONFIG_SNAPSHOT_PATH: expect.any(String)
121
- });
122
- });
123
-
124
- test('should hint essential environment variables', () => {
125
- expect(cliCall().fullCommand).toMatch(/\bDETOX_CONFIG_PATH=.*\bexecutable\b/);
126
- });
127
- });
128
-
129
- test('should use testRunner.args._ as default specs', async () => {
130
- detoxConfig.testRunner.args._ = ['e2e/sanity'];
131
- await run();
132
- expect(_.last(cliCall().argv)).toEqual('e2e/sanity');
133
- });
134
-
135
- test.each([['--config']])('%s <path> should point to the specified Jest config', async (__runnerConfig) => {
136
- await run(__runnerConfig, 'e2e/custom.config.js');
137
- expect(cliCall().argv).toEqual([expect.stringContaining('executable'), '--config', 'e2e/custom.config.js']);
138
- });
139
-
140
- test.each([['-l'], ['--loglevel']])('%s <value> should be passed as environment variable', async (__loglevel) => {
141
- await run(__loglevel, 'trace');
142
- expect(cliCall().env).toHaveProperty('DETOX_LOGLEVEL');
143
- expect(cliCall().fullCommand).toMatch(/ DETOX_LOGLEVEL="trace" /);
144
- });
145
-
146
- test.each([['-R'], ['--retries']])('%s <value> should execute successful run once', async (__retries) => {
147
- await run(__retries, 1);
148
- expect(cliCall(1)).toBe(null);
149
- });
150
-
151
- test.each([['-R'], ['--retries']])('%s <value> should execute unsuccessful run N extra times', async (__retries) => {
152
- function toTestResult(testFilePath) {
153
- return {
154
- testFilePath,
155
- success: false,
156
- isPermanentFailure: false,
157
- };
158
- }
159
-
160
- const context = require('../internals');
161
-
162
- jest.spyOn(cp, 'spawn')
163
- .mockImplementationOnce((...args) => {
164
- context.session.testResults = ['e2e/failing1.test.js', 'e2e/failing2.test.js'].map(toTestResult);
165
- return cpSpawn(...args);
166
- })
167
- .mockImplementationOnce((...args) => {
168
- context.session.testResults = ['e2e/failing2.test.js'].map(toTestResult);
169
- return cpSpawn(...args);
170
- })
171
- .mockImplementationOnce((...args) => {
172
- return cpSpawn(...args);
173
- });
174
-
175
- mockExitCode(1);
176
-
177
- await run(__retries, 2).catch(_.noop);
178
-
179
- expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json']);
180
- expect(cliCall(1).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', 'e2e/failing1.test.js', 'e2e/failing2.test.js']);
181
- expect(cliCall(2).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', 'e2e/failing2.test.js']);
182
- });
183
-
184
- describe('when there are permanently failed tests', () => {
185
- beforeEach(() => {
186
- const context = require('../internals');
187
- context.session.testResults = ['e2e/failing1.test.js', 'e2e/failing2.test.js'].map((testFilePath, index) => ({
188
- testFilePath,
189
- success: false,
190
- isPermanentFailure: index > 0,
191
- }));
192
-
193
- mockExitCode(1);
194
- });
195
-
196
- test.each([['-R'], ['--retries']])('%s <value> should not bail by default', async (__retries) => {
197
- await run(__retries, 2).catch(_.noop);
198
-
199
- expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json']);
200
- expect(cliCall(1).env).not.toHaveProperty('DETOX_RERUN_INDEX');
201
- expect(cliCall(1).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', 'e2e/failing1.test.js']);
202
- // note that it does not take the permanently failed test
203
- });
204
-
205
- test.each([['-R'], ['--retries']])('%s <value> should bail if configured', async (__retries) => {
206
- detoxConfig.testRunner.bail = true;
207
- await run(__retries, 2).catch(_.noop);
208
-
209
- expect(cliCall(0).env).not.toHaveProperty('DETOX_RERUN_INDEX');
210
- expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json']);
211
- expect(cliCall(1)).toBe(null);
212
- });
213
- });
214
-
215
- test.each([['-R'], ['--retries']])('%s <value> should not restart test runner if there are no failing tests paths', async (__retries) => {
216
- mockExitCode(1);
217
-
218
- await run(__retries, 1).catch(_.noop);
219
- expect(cliCall(0)).not.toBe(null);
220
- expect(cliCall(1)).toBe(null);
221
- });
222
-
223
- test.each([['-R'], ['--retries']])('%s <value> should retain -- <...explicitPassthroughArgs>', async (__retries) => {
224
- const context = require('../internals');
225
- context.session.testResults = [{
226
- testFilePath: 'tests/failing.test.js',
227
- success: false,
228
- isPermanentFailure: false,
229
- }];
230
-
231
- mockExitCode(1);
232
-
233
- await run(__retries, 1, 'tests', '--', '--debug').catch(_.noop);
234
-
235
- expect(cliCall(0).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', '--debug', 'tests']);
236
- expect(cliCall(1).argv).toEqual([expect.stringMatching(/executable$/), '--config', 'e2e/config.json', '--debug', 'tests/failing.test.js']);
237
- });
238
-
239
- test.each([['-r'], ['--reuse']])('%s <value> should be passed as environment variable', async (__reuse) => {
240
- await run(__reuse);
241
- expect(cliCall().env).toHaveProperty('DETOX_REUSE');
242
- expect(cliCall().fullCommand).toMatch(/\bDETOX_REUSE=true /);
243
- });
244
-
245
- test.each([['-u'], ['--cleanup']])('%s <value> should be passed as environment variable', async (__cleanup) => {
246
- await run(__cleanup);
247
- expect(cliCall().env).toHaveProperty('DETOX_CLEANUP');
248
- expect(cliCall().fullCommand).toMatch(/\bDETOX_CLEANUP=true /);
249
- });
250
-
251
- test.each([['-d'], ['--debug-synchronization']])('%s <value> should be passed as environment variable', async (__debug_synchronization) => {
252
- await run(__debug_synchronization, 5000);
253
- expect(cliCall().env).toHaveProperty('DETOX_DEBUG_SYNCHRONIZATION');
254
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEBUG_SYNCHRONIZATION=5000 /);
255
- });
256
-
257
- test.each([['-d'], ['--debug-synchronization']])('%s <value> should be passed as 0 when given false', async (__debug_synchronization) => {
258
- await run(__debug_synchronization, false);
259
- expect(cliCall().env).toHaveProperty('DETOX_DEBUG_SYNCHRONIZATION');
260
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEBUG_SYNCHRONIZATION=0 /);
261
- });
262
-
263
- test.each([['-d'], ['--debug-synchronization']])('%s <value> should have default value = 3000', async (__debug_synchronization) => {
264
- await run(`${__debug_synchronization}`);
265
- expect(cliCall().env).toHaveProperty('DETOX_DEBUG_SYNCHRONIZATION');
266
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEBUG_SYNCHRONIZATION=3000 /);
267
- });
268
-
269
- test.each([['-a'], ['--artifacts-location']])('%s <value> should be passed as environment variable', async (__artifacts_location) => {
270
- await run(__artifacts_location, '/tmp');
271
- expect(cliCall().env).toHaveProperty('DETOX_ARTIFACTS_LOCATION');
272
- expect(cliCall().fullCommand).toMatch(/\bDETOX_ARTIFACTS_LOCATION="\/tmp" /);
273
- });
274
-
275
- test('--record-logs <value> should be passed as environment variable', async () => {
276
- await run('--record-logs', 'all');
277
- expect(cliCall().env).toHaveProperty('DETOX_RECORD_LOGS');
278
- expect(cliCall().fullCommand).toMatch(/\bDETOX_RECORD_LOGS="all" /);
279
- });
280
-
281
- test('--take-screenshots <value> should be passed as environment variable', async () => {
282
- await run('--take-screenshots', 'failing');
283
- expect(cliCall().env).toHaveProperty('DETOX_TAKE_SCREENSHOTS');
284
- expect(cliCall().fullCommand).toMatch(/\bDETOX_TAKE_SCREENSHOTS="failing" /);
285
- });
286
-
287
- test('--record-videos <value> should be passed as environment variable', async () => {
288
- await run('--record-videos', 'failing');
289
- expect(cliCall().env).toHaveProperty('DETOX_RECORD_VIDEOS');
290
- expect(cliCall().fullCommand).toMatch(/\bDETOX_RECORD_VIDEOS="failing" /);
291
- });
292
-
293
- test('--record-performance <value> should be passed as environment variable', async () => {
294
- await run('--record-performance', 'all');
295
- expect(cliCall().env).toHaveProperty('DETOX_RECORD_PERFORMANCE');
296
- expect(cliCall().fullCommand).toMatch(/\DETOX_RECORD_PERFORMANCE="all" /);
297
- });
298
-
299
- test('--capture-view-hierarchy <value> should be passed as environment variable', async () => {
300
- await run('--capture-view-hierarchy', 'enabled');
301
- expect(cliCall().env).toHaveProperty('DETOX_CAPTURE_VIEW_HIERARCHY');
302
- expect(cliCall().fullCommand).toMatch(/\DETOX_CAPTURE_VIEW_HIERARCHY="enabled" /);
303
- });
304
-
305
- test('--jest-report-specs, set explicitly, should be passed as an environment variable', async () => {
306
- await run('--jest-report-specs');
307
- expect(cliCall().env).toHaveProperty('DETOX_REPORT_SPECS');
308
- expect(cliCall().fullCommand).toMatch(/\bDETOX_REPORT_SPECS=true /);
309
- });
310
-
311
- test.each([['-H'], ['--headless']])('%s <value> should be passed as environment variable', async (__headless) => {
312
- await run(__headless);
313
- expect(cliCall().env).toHaveProperty('DETOX_HEADLESS');
314
- expect(cliCall().fullCommand).toMatch(/\bDETOX_HEADLESS=true /);
315
- });
316
-
317
- test('--gpu <value> should be passed as environment variable', async () => {
318
- await run('--gpu', 'angle_indirect');
319
- expect(cliCall().env).toHaveProperty('DETOX_GPU');
320
- expect(cliCall().fullCommand).toMatch(/\bDETOX_GPU="angle_indirect" /);
321
- });
322
-
323
- test('--device-boot-args should be passed as an environment variable (without deprecation warnings)', async () => {
324
- await run('--device-boot-args="--verbose"');
325
- expect(cliCall().env).toHaveProperty('DETOX_DEVICE_BOOT_ARGS');
326
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEVICE_BOOT_ARGS="--verbose" /);
327
- expect(logger().warn).not.toHaveBeenCalledWith(DEVICE_LAUNCH_ARGS_DEPRECATION);
328
- });
329
-
330
- test('--device-launch-args should serve as a deprecated alias to --device-boot-args', async () => {
331
- await run(`--device-launch-args="--verbose"`);
332
- expect(cliCall().env).toHaveProperty('DETOX_DEVICE_BOOT_ARGS');
333
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEVICE_BOOT_ARGS="--verbose" /);
334
- expect(logger().warn).toHaveBeenCalledWith(DEVICE_LAUNCH_ARGS_DEPRECATION);
335
- });
336
-
337
- test('--app-launch-args should be passed as an environment variable', async () => {
338
- await run(`--app-launch-args="--debug yes"`);
339
- expect(cliCall().env).toHaveProperty('DETOX_APP_LAUNCH_ARGS');
340
- expect(cliCall().fullCommand).toMatch(/\bDETOX_APP_LAUNCH_ARGS="--debug yes" /);
341
- });
342
-
343
- test('--use-custom-logger false should be prevent passing environment variable', async () => {
344
- await run(`--use-custom-logger=false`);
345
- expect(cliCall().env).toHaveProperty('DETOX_USE_CUSTOM_LOGGER');
346
- expect(cliCall().fullCommand).toMatch(/\bDETOX_USE_CUSTOM_LOGGER=false /);
347
- });
348
-
349
- test('--force-adb-install should be ignored for iOS', async () => {
350
- singleConfig().device.type = 'ios.simulator';
351
- await run(`--force-adb-install`);
352
- expect(cliCall().env).not.toHaveProperty('DETOX_FORCE_ADB_INSTALL');
353
- expect(cliCall().fullCommand).not.toMatch(/DETOX_FORCE_ADB_INSTALL/);
354
- });
355
-
356
- test('--force-adb-install should be passed as environment variable', async () => {
357
- singleConfig().device.type = 'android.emulator';
358
- await run(`--force-adb-install`);
359
- expect(cliCall().env).toHaveProperty('DETOX_FORCE_ADB_INSTALL');
360
- expect(cliCall().fullCommand).toMatch(/\bDETOX_FORCE_ADB_INSTALL=true /);
361
- });
362
-
363
- test.each([['-n'], ['--device-name']])('%s <value> should be passed as environment variable', async (__device_name) => {
364
- await run(__device_name, 'TheDevice');
365
- expect(cliCall().env).toHaveProperty('DETOX_DEVICE_NAME');
366
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEVICE_NAME="TheDevice" /);
367
- });
368
-
369
- test('specifying direct test paths instead of default args._', async () => {
370
- detoxConfig.testRunner.args._ = ['e2e/'];
371
- await run('e2e/01.sanity.test.js', 'e2e/02.sanity.test.js');
372
-
373
- expect(cliCall().argv).not.toContain('e2e');
374
- expect(cliCall().argv.slice(-2)).toEqual(['e2e/01.sanity.test.js', 'e2e/02.sanity.test.js']);
375
- });
376
-
377
- test.todo('--inspect-brk should work');
378
-
379
- test.each([
380
- ['-d e2eFolder', / e2eFolder$/, /\bDETOX_DEBUG_SYNCHRONIZATION=3000/],
381
- ['--debug-synchronization e2eFolder', / e2eFolder$/, /\bDETOX_DEBUG_SYNCHRONIZATION=3000/],
382
- ['-r e2eFolder', / e2eFolder$/, /\bDETOX_REUSE=true/],
383
- ['--reuse e2eFolder', / e2eFolder$/, /\bDETOX_REUSE=true/],
384
- ['-u e2eFolder', / e2eFolder$/, /\bDETOX_CLEANUP=true/],
385
- ['--cleanup e2eFolder', / e2eFolder$/, /\bDETOX_CLEANUP=true/],
386
- ['--jest-report-specs e2eFolder', / e2eFolder$/, /\bDETOX_REPORT_SPECS=true/],
387
- ['-H e2eFolder', / e2eFolder$/, /\bDETOX_HEADLESS=true/],
388
- ['--headless e2eFolder', / e2eFolder$/, /\bDETOX_HEADLESS=true/],
389
- ['--keepLockFile e2eFolder', / e2eFolder$/, /\bDETOX_KEEP_LOCKFILE=true/],
390
- ['--use-custom-logger e2eFolder', / e2eFolder$/, /\bDETOX_USE_CUSTOM_LOGGER=true/],
391
- ['--force-adb-install e2eFolder', / e2eFolder$/, /\bDETOX_FORCE_ADB_INSTALL=true/],
392
- ])('"%s" should be disambigued correctly', async (command, commandMatcher, envMatcher) => {
393
- singleConfig().device.type = 'android.emulator';
394
- await run(...command.split(' '));
395
-
396
- expect(cliCall().argv.join(' ')).toMatch(commandMatcher);
397
- expect(cliCall().fullCommand).toEqual(expect.objectContaining(envMatcher));
398
- });
399
-
400
- test('e.g., --debug should be passed through', async () => {
401
- await run(`--debug`);
402
- expect(cliCall().argv).toContain('--debug');
403
- });
404
-
405
- test('e.g., --coverageProvider v8 should be passed through', async () => {
406
- await run('--coverageProvider', 'v8');
407
- expect(cliCall().argv.slice(-2)).toEqual(['--coverageProvider', 'v8']);
408
- });
409
-
410
- test('e.g., --debug e2e/Login.test.js should be split to --debug and e2e/Login.test.js', async () => {
411
- await run('--debug', 'e2e/Login.test.js', '--coverageProvider', 'v8');
412
-
413
- expect(cliCall().argv).toEqual([
414
- expect.stringMatching(/executable$/),
415
- '--config', 'e2e/config.json',
416
- '--debug',
417
- '--coverageProvider', 'v8',
418
- 'e2e/Login.test.js'
419
- ]);
420
- });
421
-
422
- test('should escape whitespaces when forwarding a CLI argument', async () => {
423
- await run(`e2e tests/first test.spec.js`);
424
- expect(_.last(cliCall().argv)).toEqual(`e2e tests/first test.spec.js`);
425
- });
426
-
427
- test(`should be able to use custom test runner commands`, async () => {
428
- detoxConfig.testRunner.args.$0 += ' --hello';
429
- await run();
430
- expect(cliCall().argv).toContain('--hello');
431
- });
432
-
433
- test('-- <...explicitPassthroughArgs> should be forwarded to the test runner CLI as-is', async () => {
434
- await run('--device-boot-args', 'detoxArgs', 'e2eFolder', '--', 'a', '-a', '--a', '--device-boot-args', 'runnerArgs');
435
- expect(cliCall().argv).toEqual([
436
- expect.stringMatching(/executable$/),
437
- '--config', 'e2e/config.json',
438
- 'a',
439
- '-a',
440
- '--a',
441
- '--device-boot-args',
442
- 'runnerArgs',
443
- 'e2eFolder',
444
- ]);
445
-
446
- expect(cliCall().fullCommand).toMatch(/\bDETOX_DEVICE_BOOT_ARGS="detoxArgs" /);
447
- });
448
-
449
- test('-- <...explicitPassthroughArgs> should omit double-dash "--" only once when forwarding args', async () => {
450
- await run('--', '--', '--deepParameter');
451
-
452
- expect(cliCall().argv).toContain('--');
453
- expect(cliCall().argv).toContain('--deepParameter');
454
- });
455
-
456
- // TODO: revive this test
457
- test.skip('--inspect-brk should prepend "node --inspect-brk" to the command', async () => {
458
- await run('--inspect-brk');
459
-
460
- if (process.platform === 'win32') {
461
- expect(cliCall().argv).toMatch(/^node --inspect-brk \.\/node_modules\/jest\/bin\/jest\.js/);
462
- } else {
463
- expect(cliCall().argv).toMatch(/^node --inspect-brk \.\/node_modules\/\.bin\/jest/);
464
- }
465
- });
466
-
467
- test('should append $DETOX_ARGV_OVERRIDE to detox test ... command and print a warning', async () => {
468
- process.env.PLATFORM = 'ios';
469
- process.env.DETOX_ARGV_OVERRIDE = os.platform() === 'win32'
470
- ? '--testNamePattern="[%PLATFORM%] tap" -l trace e2e/sanity/*.test.js'
471
- : '--testNamePattern="[$PLATFORM] tap" -l trace e2e/sanity/*.test.js';
472
-
473
- await run();
474
-
475
- expect(cliCall().fullCommand).toMatch(/\bDETOX_LOGLEVEL="trace" /);
476
- expect(cliCall().argv.slice(-3)).toEqual(['--testNamePattern', '[ios] tap', 'e2e/sanity/*.test.js']);
477
- expect(logger().warn).toHaveBeenCalledWith(expect.stringContaining('$DETOX_ARGV_OVERRIDE is detected'));
478
- });
479
-
480
- // Helpers
481
-
482
- function tempfile(extension, content) {
483
- const tempFilePath = require('tempfile')(extension);
484
-
485
- fs.ensureFileSync(tempFilePath);
486
- if (content) {
487
- fs.writeFileSync(tempFilePath, content);
488
- }
489
-
490
- _temporaryFiles.push(tempFilePath);
491
- return tempFilePath;
492
- }
493
-
494
- async function runRaw(...command) {
495
- let memArgv;
496
-
497
- try {
498
- memArgv = process.argv.splice(2, Infinity, ...command);
499
-
500
- return await new Promise((resolve, reject) => {
501
- const testCommand = require('./test');
502
- const originalHandler = testCommand.handler;
503
-
504
- const parser = yargs()
505
- .scriptName('detox')
506
- .parserConfiguration({
507
- 'boolean-negation': false,
508
- 'camel-case-expansion': false,
509
- 'dot-notation': false,
510
- 'duplicate-arguments-array': false,
511
- 'populate--': true,
512
- })
513
- .command({
514
- ...testCommand,
515
- async handler(argv) {
516
- try {
517
- await originalHandler(argv);
518
- resolve();
519
- } catch (e) {
520
- reject(e);
521
- }
522
- },
523
- })
524
- .wrap(null);
525
-
526
- parser.parse(command, err => err && reject(err));
527
- });
528
- } finally {
529
- memArgv && process.argv.splice(2, Infinity, ...memArgv);
530
- }
531
- }
532
-
533
- async function run(...args) {
534
- detoxConfigPath = tempfile('.json', JSON.stringify(detoxConfig));
535
- const __configPath = Math.random() > 0.5 ? '-C' : '--config-path';
536
- return runRaw('test', __configPath, detoxConfigPath, ...args);
537
- }
538
-
539
- function cliCall(index = 0) {
540
- if (!_cliCallDump) {
541
- _cliCallDump = fs.readFileSync(process.env.CLI_TEST_STDOUT, 'utf8')
542
- .split('\n')
543
- .filter(Boolean)
544
- .map(line => JSON.parse(line));
545
- }
546
-
547
- const mockCall = _cliCallDump[index];
548
- if (!mockCall) {
549
- return null;
550
- }
551
-
552
- return {
553
- ...mockCall,
554
- fullCommand: _.chain(logger().log.mock.calls)
555
- .filter(([_level, _childMeta, meta]) => meta && meta.env)
556
- .get(index)
557
- .get(3)
558
- .value(),
559
- };
560
- }
561
-
562
- function singleConfig() {
563
- return Object.values(detoxConfig.configurations)[0];
564
- }
565
-
566
- function mockExitCode(code) {
567
- process.env.CLI_EXIT_CODE = code;
568
- }
569
- });
@@ -1,25 +0,0 @@
1
- const chalk = require('chalk');
2
-
3
- // @ts-ignore
4
- console.error(chalk.yellow(`
5
- ========================= THE NEW JOURNEY BEGINS =============================
6
-
7
- https://wix.github.io/Detox/docs/guide/jest
8
-
9
- Sorry to say that Detox 20 comes without old adapters for Jest.
10
- You have to rearrange your init code before you can continue your journey.
11
-
12
- Navigate to the link and follow the migration guide steps.
13
-
14
- Sincerely yours,
15
- Detox team.
16
-
17
- https://wix.github.io/Detox/docs/guide/jest
18
-
19
- ========================= THE NEW JOURNEY BEGINS =============================
20
-
21
- `));
22
-
23
- throw Object.assign(new Error(
24
- '\n\nPlease follow the new Jest setup guide:\nhttps://wix.github.io/Detox/docs/guide/jest\n\n'
25
- ), { stack: '' });
@@ -1,23 +0,0 @@
1
- const { assertSupportedVersion } = require('./assertJestCircus27');
2
-
3
- describe('assertSupportedVersion', () => {
4
- test.each([
5
- ['27.2.5'],
6
- ['27.2.6-prerelease.0'],
7
- ['27.3.0'],
8
- ['28.0.0-alpha.1'],
9
- ['28.0.0'],
10
- ['28.1.0'],
11
- ['29.0.0-next.0'],
12
- ['30.0.0'],
13
- ])('should pass for %j', (version) => {
14
- expect(() => assertSupportedVersion(version)).not.toThrow();
15
- });
16
-
17
- test.each([
18
- ['26.0.0'],
19
- ['27.2.4'],
20
- ])('should throw an error for %j', (version) => {
21
- expect(() => assertSupportedVersion(version)).toThrowError(/unsupported jest.*version/);
22
- });
23
- });
@@ -1,12 +0,0 @@
1
- const DEVICE_LAUNCH_ARGS_DEPRECATION = `\
2
- --device-launch-args is a deprecated name of this option.
3
- Please change your scripts to use --device-boot-args instead.`;
4
-
5
- const DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION = `\
6
- --device-launch-args / $DETOX_DEVICE_LAUNCH_ARGS is a deprecated name of this option.
7
- Please change your scripts to use --device-boot-args / $DETOX_DEVICE_BOOT_ARGS instead.`;
8
-
9
- module.exports = {
10
- DEVICE_LAUNCH_ARGS_DEPRECATION,
11
- DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION,
12
- };