detox 20.0.15-prerelease.0 → 20.1.0

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