@nyby/detox-component-testing 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -50
- package/dist/ComponentHarness.d.ts +1 -1
- package/dist/ComponentHarness.d.ts.map +1 -1
- package/dist/ComponentHarness.js +10 -12
- package/dist/ComponentHarness.js.map +1 -1
- package/dist/ComponentRegistry.d.ts +1 -1
- package/dist/ComponentRegistry.d.ts.map +1 -1
- package/dist/ComponentRegistry.js +2 -2
- package/dist/ComponentRegistry.js.map +1 -1
- package/dist/configureHarness.d.ts +1 -4
- package/dist/configureHarness.d.ts.map +1 -1
- package/dist/configureHarness.js +0 -12
- package/dist/configureHarness.js.map +1 -1
- package/dist/debug.d.ts +8 -0
- package/dist/debug.d.ts.map +1 -1
- package/dist/debug.js +26 -32
- package/dist/debug.js.map +1 -1
- package/dist/environment.js +7 -37
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/mount.d.ts +0 -1
- package/dist/mount.d.ts.map +1 -1
- package/dist/mount.js +9 -10
- package/dist/mount.js.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js.map +1 -1
- package/package.json +3 -3
- package/src/ComponentHarness.tsx +46 -37
- package/src/ComponentRegistry.ts +7 -4
- package/src/configureHarness.ts +2 -14
- package/src/debug.ts +34 -34
- package/src/detox-env.d.ts +1 -1
- package/src/environment.js +7 -37
- package/src/index.ts +7 -4
- package/src/mount.ts +26 -15
- package/src/test.ts +2 -2
- package/dist/DebugTree.d.ts +0 -20
- package/dist/DebugTree.d.ts.map +0 -1
- package/dist/DebugTree.js +0 -239
- package/dist/DebugTree.js.map +0 -1
- package/src/DebugTree.tsx +0 -280
package/README.md
CHANGED
|
@@ -40,7 +40,6 @@ configureHarness({
|
|
|
40
40
|
wrapper: ({children}) => (
|
|
41
41
|
<View style={{flex: 1}}>{children}</View>
|
|
42
42
|
),
|
|
43
|
-
debugTree: true,
|
|
44
43
|
});
|
|
45
44
|
|
|
46
45
|
AppRegistry.registerComponent('example', () => ComponentHarness);
|
|
@@ -190,7 +189,6 @@ Subsequent mounts: ~100ms (in-place swap)
|
|
|
190
189
|
### App-side (import from `@nyby/detox-component-testing`)
|
|
191
190
|
|
|
192
191
|
#### `registerComponent(Component, defaultProps?)`
|
|
193
|
-
|
|
194
192
|
#### `registerComponent(name, Component, defaultProps?)`
|
|
195
193
|
|
|
196
194
|
Register a component for testing. When called with just a component, the name is inferred from `Component.name` or `Component.displayName`.
|
|
@@ -199,9 +197,9 @@ Register a component for testing. When called with just a component, the name is
|
|
|
199
197
|
|
|
200
198
|
Root component for the test harness. Register as your app's root component in the component test entry point.
|
|
201
199
|
|
|
202
|
-
#### `configureHarness({ wrapper
|
|
200
|
+
#### `configureHarness({ wrapper? })`
|
|
203
201
|
|
|
204
|
-
Set a global wrapper component
|
|
202
|
+
Set a global wrapper component for all mounted components:
|
|
205
203
|
|
|
206
204
|
```js
|
|
207
205
|
import {Provider} from 'react-redux';
|
|
@@ -216,14 +214,11 @@ configureHarness({
|
|
|
216
214
|
}
|
|
217
215
|
return <Provider store={store}>{children}</Provider>;
|
|
218
216
|
},
|
|
219
|
-
debugTree: true,
|
|
220
217
|
});
|
|
221
218
|
```
|
|
222
219
|
|
|
223
220
|
The wrapper receives `launchArgs` — the props passed to `mount()` — so you can configure per-test state.
|
|
224
221
|
|
|
225
|
-
The `debugTree` option enables component tree capture for `debug()` and the custom test environment. Pass `true` for defaults, or an object with `usefulProps`, `skipNames`, and/or `nativeDuplicates` to customize filtering (see [DebugTree](#debugtree) below).
|
|
226
|
-
|
|
227
222
|
### Test-side (import from `@nyby/detox-component-testing/test`)
|
|
228
223
|
|
|
229
224
|
#### `mount(componentName, props?)`
|
|
@@ -244,65 +239,26 @@ Returns an assertion object for a spy:
|
|
|
244
239
|
|
|
245
240
|
#### `debug(label?, outputDir?)`
|
|
246
241
|
|
|
247
|
-
Capture a screenshot
|
|
242
|
+
Capture a screenshot and native view hierarchy for the current screen state. Useful for debugging test failures or inspecting what's on screen at any point in a test.
|
|
248
243
|
|
|
249
244
|
```ts
|
|
250
245
|
import {mount, debug} from '@nyby/detox-component-testing/test';
|
|
251
246
|
|
|
252
247
|
it('renders the event screen', async () => {
|
|
253
248
|
await mount('EventScreen', {eventId: 'event_1'});
|
|
254
|
-
await debug('after-mount'); // writes to artifacts/debug-after-mount.{png,
|
|
249
|
+
await debug('after-mount'); // writes to artifacts/debug-after-mount.{png,xml}
|
|
255
250
|
});
|
|
256
251
|
```
|
|
257
252
|
|
|
258
|
-
Each call writes up to
|
|
253
|
+
Each call writes up to two files to the output directory (defaults to `<cwd>/artifacts`):
|
|
259
254
|
|
|
260
255
|
- `debug-<label>.png` — screenshot
|
|
261
|
-
- `debug-<label>-tree.json` — React component tree (requires `DebugTree` wrapper)
|
|
262
256
|
- `debug-<label>-view.xml` — native view hierarchy
|
|
263
257
|
|
|
264
258
|
If no label is provided, calls are numbered automatically (`1`, `2`, `3`, ...).
|
|
265
259
|
|
|
266
260
|
### Debugging
|
|
267
261
|
|
|
268
|
-
#### `DebugTree`
|
|
269
|
-
|
|
270
|
-
A component that captures the React fiber tree on demand. Enable it via `configureHarness({ debugTree: true })` to get component tree capture in `debug()` and the custom test environment.
|
|
271
|
-
|
|
272
|
-
```js
|
|
273
|
-
import {configureHarness} from '@nyby/detox-component-testing';
|
|
274
|
-
|
|
275
|
-
configureHarness({
|
|
276
|
-
wrapper: ({children}) => (
|
|
277
|
-
<Provider store={store}>{children}</Provider>
|
|
278
|
-
),
|
|
279
|
-
debugTree: true,
|
|
280
|
-
});
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
You can also pass filtering options directly:
|
|
284
|
-
|
|
285
|
-
```js
|
|
286
|
-
configureHarness({
|
|
287
|
-
debugTree: {
|
|
288
|
-
usefulProps: ['testID', 'accessibilityLabel', 'title'],
|
|
289
|
-
skipNames: ['MyInternalWrapper'],
|
|
290
|
-
},
|
|
291
|
-
});
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
`DebugTree` walks the React fiber tree and produces a JSON snapshot of component names, key props (`testID`, `accessibilityLabel`, `variant`, `onPress`, etc.), and text content. The output filters noise — internal wrappers and native duplicates are excluded by default.
|
|
295
|
-
|
|
296
|
-
The `DebugTree` component is also exported for advanced use cases where you need direct control.
|
|
297
|
-
|
|
298
|
-
All filtering lists are configurable:
|
|
299
|
-
|
|
300
|
-
| Prop | Type | Description |
|
|
301
|
-
| ------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
302
|
-
| `usefulProps` | `string[]` | Props to include in output. Defaults to `testID`, `accessibilityLabel`, `title`, `value`, `placeholder`, `disabled`, etc. |
|
|
303
|
-
| `skipNames` | `string[]` | Component names to skip. Defaults to internal wrappers like `StaticContainer`, `PressabilityDebugView`, etc. |
|
|
304
|
-
| `nativeDuplicates` | `string[]` | Native components that duplicate their parent. Defaults to `RCTText`, `RCTView`, etc. |
|
|
305
|
-
|
|
306
262
|
#### Custom test environment
|
|
307
263
|
|
|
308
264
|
A Detox Jest environment that automatically captures debug artifacts when a test fails. Use it instead of the default Detox environment:
|
|
@@ -318,7 +274,6 @@ module.exports = {
|
|
|
318
274
|
On test failure, it captures:
|
|
319
275
|
|
|
320
276
|
- A screenshot
|
|
321
|
-
- The React component tree (if `DebugTree` is in the wrapper)
|
|
322
277
|
- The native view hierarchy
|
|
323
278
|
|
|
324
279
|
All artifacts are written to `<cwd>/artifacts/`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentHarness.d.ts","sourceRoot":"","sources":["../src/ComponentHarness.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ComponentHarness.d.ts","sourceRoot":"","sources":["../src/ComponentHarness.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AA4Df,wBAAgB,gBAAgB,sBAkD/B"}
|
package/dist/ComponentHarness.js
CHANGED
|
@@ -39,7 +39,6 @@ const react_native_1 = require("react-native");
|
|
|
39
39
|
const react_native_launch_arguments_1 = require("react-native-launch-arguments");
|
|
40
40
|
const ComponentRegistry_1 = require("./ComponentRegistry");
|
|
41
41
|
const configureHarness_1 = require("./configureHarness");
|
|
42
|
-
const DebugTree_1 = require("./DebugTree");
|
|
43
42
|
class RenderErrorBoundary extends react_1.Component {
|
|
44
43
|
constructor() {
|
|
45
44
|
super(...arguments);
|
|
@@ -56,8 +55,8 @@ class RenderErrorBoundary extends react_1.Component {
|
|
|
56
55
|
return this.props.children;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
const PROP_PREFIX =
|
|
60
|
-
const SPY_PREFIX =
|
|
58
|
+
const PROP_PREFIX = "detoxProp_";
|
|
59
|
+
const SPY_PREFIX = "detoxSpy_";
|
|
61
60
|
function parseLaunchArgs(args) {
|
|
62
61
|
const props = {};
|
|
63
62
|
const spies = [];
|
|
@@ -87,7 +86,7 @@ function ComponentHarness() {
|
|
|
87
86
|
else if (launchArgs.detoxComponentName) {
|
|
88
87
|
const { props, spies } = parseLaunchArgs(launchArgs);
|
|
89
88
|
activeMount = {
|
|
90
|
-
id:
|
|
89
|
+
id: "0",
|
|
91
90
|
name: launchArgs.detoxComponentName,
|
|
92
91
|
props,
|
|
93
92
|
spies,
|
|
@@ -95,7 +94,7 @@ function ComponentHarness() {
|
|
|
95
94
|
}
|
|
96
95
|
return (react_1.default.createElement(react_native_1.View, { style: { flex: 1 } },
|
|
97
96
|
react_1.default.createElement(react_native_1.TextInput, { testID: "detox-harness-control", onEndEditing: handleControl, style: {
|
|
98
|
-
position:
|
|
97
|
+
position: "absolute",
|
|
99
98
|
bottom: 0,
|
|
100
99
|
left: 0,
|
|
101
100
|
right: 0,
|
|
@@ -137,12 +136,11 @@ function ComponentRenderer({ mount }) {
|
|
|
137
136
|
});
|
|
138
137
|
const props = { ...defaultProps, ...(mount.props || {}), ...spyProps };
|
|
139
138
|
const Wrapper = (0, configureHarness_1.getWrapper)();
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return (react_1.default.createElement(Wrapper, { launchArgs: mount.props || {} }, debugTreeConfig ? react_1.default.createElement(DebugTree_1.DebugTree, { ...debugTreeConfig }, content) : content));
|
|
139
|
+
return (react_1.default.createElement(Wrapper, { launchArgs: mount.props || {} },
|
|
140
|
+
react_1.default.createElement(react_native_1.View, { testID: "component-harness-root", style: { flex: 1 } },
|
|
141
|
+
react_1.default.createElement(Component, { ...props }),
|
|
142
|
+
spyNames.map((name) => (react_1.default.createElement(react_native_1.View, { key: name },
|
|
143
|
+
react_1.default.createElement(react_native_1.Text, { testID: `spy-${name}-count` }, String(spyData[name].count)),
|
|
144
|
+
react_1.default.createElement(react_native_1.Text, { testID: `spy-${name}-lastArgs` }, JSON.stringify(spyData[name].lastArgs))))))));
|
|
147
145
|
}
|
|
148
146
|
//# sourceMappingURL=ComponentHarness.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentHarness.js","sourceRoot":"","sources":["../src/ComponentHarness.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ComponentHarness.js","sourceRoot":"","sources":["../src/ComponentHarness.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,4CAkDC;AApHD,+CAMe;AACf,+CAAiE;AACjE,iFAAgE;AAChE,2DAAmD;AACnD,yDAAgD;AAMhD,MAAM,mBAAoB,SAAQ,iBAGjC;IAHD;;QAIE,UAAK,GAAuB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAkB9C,CAAC;IAhBC,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,OAAO,EAAE,KAAK,EAAE,CA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AAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC;IACvE,MAAM,OAAO,GAAG,IAAA,6BAAU,GAAE,CAAC;IAE7B,OAAO,CACL,8BAAC,OAAO,IAAC,UAAU,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;QACpC,8BAAC,mBAAI,IAAC,MAAM,EAAC,wBAAwB,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;YACtD,8BAAC,SAAS,OAAK,KAAK,GAAI;YACvB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACtB,8BAAC,mBAAI,IAAC,GAAG,EAAE,IAAI;gBACb,8BAAC,mBAAI,IAAC,MAAM,EAAE,OAAO,IAAI,QAAQ,IAC9B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CACvB;gBACP,8BAAC,mBAAI,IAAC,MAAM,EAAE,OAAO,IAAI,WAAW,IACjC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAClC,CACF,CACR,CAAC,CACG,CACC,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../src/ComponentRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../src/ComponentRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAC1B;AAID,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACxB,IAAI,CAAC;AACR,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACxB,IAAI,CAAC;AA0BR,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAQzD;AAED,wBAAgB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAEvD"}
|
|
@@ -5,7 +5,7 @@ exports.getComponent = getComponent;
|
|
|
5
5
|
exports.getAll = getAll;
|
|
6
6
|
const registry = new Map();
|
|
7
7
|
function registerComponent(nameOrComponent, componentOrProps, defaultProps) {
|
|
8
|
-
if (typeof nameOrComponent ===
|
|
8
|
+
if (typeof nameOrComponent === "string") {
|
|
9
9
|
registry.set(nameOrComponent, {
|
|
10
10
|
Component: componentOrProps,
|
|
11
11
|
defaultProps: (defaultProps || {}),
|
|
@@ -15,7 +15,7 @@ function registerComponent(nameOrComponent, componentOrProps, defaultProps) {
|
|
|
15
15
|
const Component = nameOrComponent;
|
|
16
16
|
const name = Component.displayName || Component.name;
|
|
17
17
|
if (!name) {
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error("[detox-component-testing] Component must have a name or displayName to register without an explicit name.");
|
|
19
19
|
}
|
|
20
20
|
registry.set(name, {
|
|
21
21
|
Component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentRegistry.js","sourceRoot":"","sources":["../src/ComponentRegistry.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.js","sourceRoot":"","sources":["../src/ComponentRegistry.ts"],"names":[],"mappings":";;AAkBA,8CAuBC;AAED,oCAQC;AAED,wBAEC;AAhDD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;AAWnD,SAAgB,iBAAiB,CAC/B,eAA0C,EAC1C,gBAAgD,EAChD,YAAyB;IAEzB,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE;YAC5B,SAAS,EAAE,gBAAoC;YAC/C,YAAY,EAAE,CAAC,YAAY,IAAI,EAAE,CAAe;SACjD,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,GAAG,eAAe,CAAC;QAClC,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,CAAC;QACrD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;QACJ,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE;YACjB,SAAS;YACT,YAAY,EAAE,CAAE,gBAA+B,IAAI,EAAE,CAAe;SACrE,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,4DAA4D,CACzG,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,MAAM;IACpB,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from
|
|
2
|
-
import { DebugTreeProps } from './DebugTree';
|
|
1
|
+
import { ComponentType, ReactNode } from "react";
|
|
3
2
|
export interface WrapperProps {
|
|
4
3
|
children: ReactNode;
|
|
5
4
|
launchArgs: Record<string, any>;
|
|
6
5
|
}
|
|
7
6
|
export interface HarnessConfig {
|
|
8
7
|
wrapper?: ComponentType<WrapperProps>;
|
|
9
|
-
debugTree?: boolean | Omit<DebugTreeProps, 'children'>;
|
|
10
8
|
}
|
|
11
9
|
export declare function configureHarness(config: HarnessConfig): void;
|
|
12
10
|
export declare function getWrapper(): ComponentType<WrapperProps>;
|
|
13
|
-
export declare function getDebugTreeConfig(): Omit<DebugTreeProps, 'children'> | null;
|
|
14
11
|
//# sourceMappingURL=configureHarness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureHarness.d.ts","sourceRoot":"","sources":["../src/configureHarness.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"configureHarness.d.ts","sourceRoot":"","sources":["../src/configureHarness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACvC;AAMD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAI5D;AAED,wBAAgB,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,CAExD"}
|
package/dist/configureHarness.js
CHANGED
|
@@ -2,26 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configureHarness = configureHarness;
|
|
4
4
|
exports.getWrapper = getWrapper;
|
|
5
|
-
exports.getDebugTreeConfig = getDebugTreeConfig;
|
|
6
5
|
const DefaultWrapper = ({ children }) => children;
|
|
7
6
|
let globalWrapper = null;
|
|
8
|
-
let globalDebugTree = null;
|
|
9
7
|
function configureHarness(config) {
|
|
10
8
|
if (config.wrapper) {
|
|
11
9
|
globalWrapper = config.wrapper;
|
|
12
10
|
}
|
|
13
|
-
if (config.debugTree !== undefined) {
|
|
14
|
-
globalDebugTree = config.debugTree;
|
|
15
|
-
}
|
|
16
11
|
}
|
|
17
12
|
function getWrapper() {
|
|
18
13
|
return globalWrapper || DefaultWrapper;
|
|
19
14
|
}
|
|
20
|
-
function getDebugTreeConfig() {
|
|
21
|
-
if (!globalDebugTree)
|
|
22
|
-
return null;
|
|
23
|
-
if (globalDebugTree === true)
|
|
24
|
-
return {};
|
|
25
|
-
return globalDebugTree;
|
|
26
|
-
}
|
|
27
15
|
//# sourceMappingURL=configureHarness.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureHarness.js","sourceRoot":"","sources":["../src/configureHarness.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"configureHarness.js","sourceRoot":"","sources":["../src/configureHarness.ts"],"names":[],"mappings":";;AAeA,4CAIC;AAED,gCAEC;AAZD,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC;AAEhE,IAAI,aAAa,GAAuC,IAAI,CAAC;AAE7D,SAAgB,gBAAgB,CAAC,MAAqB;IACpD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,CAAC;AACH,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,aAAa,IAAI,cAAc,CAAC;AACzC,CAAC"}
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a screenshot and native view hierarchy to the given directory.
|
|
3
|
+
* Used by both the `debug()` helper and the custom test environment.
|
|
4
|
+
*/
|
|
5
|
+
export declare function captureArtifacts(name: string, outputDir: string, deviceRef: {
|
|
6
|
+
takeScreenshot: (n: string) => Promise<string>;
|
|
7
|
+
generateViewHierarchyXml: () => Promise<string>;
|
|
8
|
+
}): Promise<void>;
|
|
1
9
|
export declare function debug(label?: string, outputDir?: string): Promise<void>;
|
|
2
10
|
//# sourceMappingURL=debug.d.ts.map
|
package/dist/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE;IACT,cAAc,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,wBAAwB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD,iBAiBF;AAaD,wBAAsB,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,iBAI7D"}
|
package/dist/debug.js
CHANGED
|
@@ -1,49 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.captureArtifacts = captureArtifacts;
|
|
3
4
|
exports.debug = debug;
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
/**
|
|
7
|
-
* Capture a screenshot
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* import { debug } from '@nyby/detox-component-testing/test';
|
|
12
|
-
* await debug(); // artifacts/debug-1.png, debug-1-tree.json, debug-1-view.xml
|
|
13
|
-
* await debug('after-tap'); // artifacts/debug-after-tap.png, etc.
|
|
8
|
+
* Capture a screenshot and native view hierarchy to the given directory.
|
|
9
|
+
* Used by both the `debug()` helper and the custom test environment.
|
|
14
10
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const name = label || String(++counter);
|
|
18
|
-
const dir = outputDir || (0, path_1.join)(process.cwd(), 'artifacts');
|
|
19
|
-
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
20
|
-
const screenshotPath = (0, path_1.join)(dir, `debug-${name}.png`);
|
|
21
|
-
const treePath = (0, path_1.join)(dir, `debug-${name}-tree.json`);
|
|
22
|
-
const viewPath = (0, path_1.join)(dir, `debug-${name}-view.xml`);
|
|
11
|
+
async function captureArtifacts(name, outputDir, deviceRef) {
|
|
12
|
+
(0, fs_1.mkdirSync)(outputDir, { recursive: true });
|
|
23
13
|
// Screenshot via Detox, then move to our artifacts dir
|
|
24
14
|
try {
|
|
25
|
-
const tempPath = await
|
|
15
|
+
const tempPath = await deviceRef.takeScreenshot(`debug-${name}`);
|
|
26
16
|
if (tempPath) {
|
|
27
|
-
(0, fs_1.renameSync)(tempPath,
|
|
17
|
+
(0, fs_1.renameSync)(tempPath, (0, path_1.join)(outputDir, `debug-${name}.png`));
|
|
28
18
|
}
|
|
29
19
|
}
|
|
30
|
-
catch
|
|
31
|
-
// React component tree via DebugTree harness
|
|
32
|
-
try {
|
|
33
|
-
await element(by.id('debug-tree-control')).replaceText('dump');
|
|
34
|
-
await waitFor(element(by.id('debug-tree-output')))
|
|
35
|
-
.toExist()
|
|
36
|
-
.withTimeout(3000);
|
|
37
|
-
const attrs = await element(by.id('debug-tree-output')).getAttributes();
|
|
38
|
-
const tree = attrs.text || attrs.label || '[]';
|
|
39
|
-
(0, fs_1.writeFileSync)(treePath, tree, 'utf8');
|
|
40
|
-
}
|
|
41
|
-
catch (_b) { }
|
|
20
|
+
catch { }
|
|
42
21
|
// Native view hierarchy
|
|
43
22
|
try {
|
|
44
|
-
const xml = await
|
|
45
|
-
(0, fs_1.writeFileSync)(
|
|
23
|
+
const xml = await deviceRef.generateViewHierarchyXml();
|
|
24
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(outputDir, `debug-${name}-view.xml`), xml, "utf8");
|
|
46
25
|
}
|
|
47
|
-
catch
|
|
26
|
+
catch { }
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Capture a screenshot and native view hierarchy.
|
|
30
|
+
* Drop this anywhere in a test to inspect the current screen state.
|
|
31
|
+
*
|
|
32
|
+
* Usage:
|
|
33
|
+
* import { debug } from '@nyby/detox-component-testing/test';
|
|
34
|
+
* await debug(); // artifacts/debug-1.png, debug-1-view.xml
|
|
35
|
+
* await debug('after-tap'); // artifacts/debug-after-tap.png, etc.
|
|
36
|
+
*/
|
|
37
|
+
let counter = 0;
|
|
38
|
+
async function debug(label, outputDir) {
|
|
39
|
+
const name = label || String(++counter);
|
|
40
|
+
const dir = outputDir || (0, path_1.join)(process.cwd(), "artifacts");
|
|
41
|
+
await captureArtifacts(name, dir, device);
|
|
48
42
|
}
|
|
49
43
|
//# sourceMappingURL=debug.js.map
|
package/dist/debug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":";;AAOA,4CAuBC;AAaD,sBAIC;AA/CD,2BAA0D;AAC1D,+BAA4B;AAE5B;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,SAAiB,EACjB,SAGC;IAED,IAAA,cAAS,EAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1C,uDAAuD;IACvD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACjE,IAAI,QAAQ,EAAE,CAAC;YACb,IAAA,eAAU,EAAC,QAAQ,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,wBAAwB;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,wBAAwB,EAAE,CAAC;QACvD,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,SAAS,IAAI,WAAW,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED;;;;;;;;GAQG;AACH,IAAI,OAAO,GAAG,CAAC,CAAC;AAET,KAAK,UAAU,KAAK,CAAC,KAAc,EAAE,SAAkB;IAC5D,MAAM,IAAI,GAAG,KAAK,IAAI,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,SAAS,IAAI,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;IAC1D,MAAM,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/environment.js
CHANGED
|
@@ -1,47 +1,17 @@
|
|
|
1
|
-
const DetoxCircusEnvironment = require(
|
|
2
|
-
const {
|
|
3
|
-
const {
|
|
1
|
+
const DetoxCircusEnvironment = require("detox/runners/jest/testEnvironment");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
const { captureArtifacts } = require("./debug");
|
|
4
4
|
|
|
5
5
|
class CustomDetoxEnvironment extends DetoxCircusEnvironment {
|
|
6
6
|
async handleTestEvent(event, state) {
|
|
7
7
|
await super.handleTestEvent(event, state);
|
|
8
8
|
|
|
9
|
-
if (event.name ===
|
|
10
|
-
|
|
9
|
+
if (event.name === "test_done" && event.test.errors.length > 0) {
|
|
10
|
+
const safeName = event.test.name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
11
|
+
const outputDir = join(process.cwd(), "artifacts");
|
|
12
|
+
await captureArtifacts(safeName, outputDir, this.global.device);
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
async _dumpDebugInfo(test) {
|
|
15
|
-
const outputDir = join(process.cwd(), 'artifacts');
|
|
16
|
-
const safeName = test.name.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
17
|
-
|
|
18
|
-
mkdirSync(outputDir, {recursive: true});
|
|
19
|
-
|
|
20
|
-
// Screenshot (saved by Detox into its own artifacts folder)
|
|
21
|
-
try {
|
|
22
|
-
await this.global.device.takeScreenshot(`debug-${safeName}`);
|
|
23
|
-
} catch (_e) {}
|
|
24
|
-
|
|
25
|
-
// Component tree via DebugTree
|
|
26
|
-
try {
|
|
27
|
-
const {element, by, waitFor} = this.global;
|
|
28
|
-
|
|
29
|
-
await element(by.id('debug-tree-control')).replaceText('dump');
|
|
30
|
-
await waitFor(element(by.id('debug-tree-output')))
|
|
31
|
-
.toExist()
|
|
32
|
-
.withTimeout(3000);
|
|
33
|
-
|
|
34
|
-
const attrs = await element(by.id('debug-tree-output')).getAttributes();
|
|
35
|
-
const tree = attrs.text || attrs.label || '[]';
|
|
36
|
-
writeFileSync(join(outputDir, `componenttree-${safeName}.json`), tree, 'utf8');
|
|
37
|
-
} catch (_e) {}
|
|
38
|
-
|
|
39
|
-
// Native view hierarchy
|
|
40
|
-
try {
|
|
41
|
-
const xml = await this.global.device.generateViewHierarchyXml();
|
|
42
|
-
writeFileSync(join(outputDir, `viewhierarchy-${safeName}.xml`), xml, 'utf8');
|
|
43
|
-
} catch (_e) {}
|
|
44
|
-
}
|
|
45
15
|
}
|
|
46
16
|
|
|
47
17
|
module.exports = CustomDetoxEnvironment;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { registerComponent } from
|
|
2
|
-
export { ComponentHarness } from
|
|
3
|
-
export { configureHarness, WrapperProps, HarnessConfig } from
|
|
4
|
-
export { DebugTree, DebugTreeProps } from './DebugTree';
|
|
1
|
+
export { registerComponent } from "./ComponentRegistry";
|
|
2
|
+
export { ComponentHarness } from "./ComponentHarness";
|
|
3
|
+
export { configureHarness, WrapperProps, HarnessConfig, } from "./configureHarness";
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.configureHarness = exports.ComponentHarness = exports.registerComponent = void 0;
|
|
4
4
|
var ComponentRegistry_1 = require("./ComponentRegistry");
|
|
5
5
|
Object.defineProperty(exports, "registerComponent", { enumerable: true, get: function () { return ComponentRegistry_1.registerComponent; } });
|
|
6
6
|
var ComponentHarness_1 = require("./ComponentHarness");
|
|
7
7
|
Object.defineProperty(exports, "ComponentHarness", { enumerable: true, get: function () { return ComponentHarness_1.ComponentHarness; } });
|
|
8
8
|
var configureHarness_1 = require("./configureHarness");
|
|
9
9
|
Object.defineProperty(exports, "configureHarness", { enumerable: true, get: function () { return configureHarness_1.configureHarness; } });
|
|
10
|
-
var DebugTree_1 = require("./DebugTree");
|
|
11
|
-
Object.defineProperty(exports, "DebugTree", { enumerable: true, get: function () { return DebugTree_1.DebugTree; } });
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,uDAI4B;AAH1B,oHAAA,gBAAgB,OAAA"}
|
package/dist/mount.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export interface SpyExpectation {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function spy(name: string): SpyMarker;
|
|
11
11
|
type MountProps = Record<string, string | number | boolean | SpyMarker>;
|
|
12
|
-
export declare function assertNoRenderError(): Promise<void>;
|
|
13
12
|
export declare function mount(componentName: string, props?: MountProps): Promise<void>;
|
|
14
13
|
export declare function expectSpy(name: string): SpyExpectation;
|
|
15
14
|
export {};
|
package/dist/mount.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,cAAc,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAOD,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAE3C;AAED,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,cAAc,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAOD,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAE3C;AAED,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAkBxE,wBAAsB,KAAK,CACzB,aAAa,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAqBtD"}
|
package/dist/mount.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.spy = spy;
|
|
4
|
-
exports.assertNoRenderError = assertNoRenderError;
|
|
5
4
|
exports.mount = mount;
|
|
6
5
|
exports.expectSpy = expectSpy;
|
|
7
|
-
const SPY_MARKER =
|
|
6
|
+
const SPY_MARKER = "__detoxSpy__";
|
|
8
7
|
let mountCounter = 0;
|
|
9
8
|
let appLaunched = false;
|
|
10
9
|
function spy(name) {
|
|
@@ -12,16 +11,16 @@ function spy(name) {
|
|
|
12
11
|
}
|
|
13
12
|
async function assertNoRenderError() {
|
|
14
13
|
try {
|
|
15
|
-
await waitFor(element(by.id(
|
|
14
|
+
await waitFor(element(by.id("detox-render-error")))
|
|
16
15
|
.toExist()
|
|
17
16
|
.withTimeout(500);
|
|
18
17
|
}
|
|
19
|
-
catch
|
|
18
|
+
catch {
|
|
20
19
|
return; // Element not found — no render error, all good
|
|
21
20
|
}
|
|
22
21
|
// Element exists — read the error message and throw
|
|
23
|
-
const attrs = (await element(by.id(
|
|
24
|
-
const message = attrs.text || attrs.label ||
|
|
22
|
+
const attrs = (await element(by.id("detox-render-error-message")).getAttributes());
|
|
23
|
+
const message = attrs.text || attrs.label || "Unknown render error";
|
|
25
24
|
throw new Error(`Component render error: ${message}`);
|
|
26
25
|
}
|
|
27
26
|
async function mount(componentName, props) {
|
|
@@ -33,7 +32,7 @@ async function mount(componentName, props) {
|
|
|
33
32
|
};
|
|
34
33
|
if (props) {
|
|
35
34
|
Object.entries(props).forEach(([key, value]) => {
|
|
36
|
-
if (value && typeof value ===
|
|
35
|
+
if (value && typeof value === "object" && SPY_MARKER in value) {
|
|
37
36
|
payload.spies.push(key);
|
|
38
37
|
}
|
|
39
38
|
else {
|
|
@@ -52,8 +51,8 @@ async function mount(componentName, props) {
|
|
|
52
51
|
appLaunched = true;
|
|
53
52
|
// Harness sets id '0' for the initial launch-args mount
|
|
54
53
|
try {
|
|
55
|
-
await waitFor(element(by.id(
|
|
56
|
-
.toHaveText(
|
|
54
|
+
await waitFor(element(by.id("detox-mount-id")))
|
|
55
|
+
.toHaveText("0")
|
|
57
56
|
.withTimeout(5000);
|
|
58
57
|
}
|
|
59
58
|
catch (e) {
|
|
@@ -68,7 +67,7 @@ function expectSpy(name) {
|
|
|
68
67
|
const getExpect = () => expect;
|
|
69
68
|
return {
|
|
70
69
|
async toHaveBeenCalled() {
|
|
71
|
-
await getExpect()(element(by.id(`spy-${name}-count`))).not.toHaveText(
|
|
70
|
+
await getExpect()(element(by.id(`spy-${name}-count`))).not.toHaveText("0");
|
|
72
71
|
},
|
|
73
72
|
async toHaveBeenCalledTimes(n) {
|
|
74
73
|
await getExpect()(element(by.id(`spy-${name}-count`))).toHaveText(String(n));
|
package/dist/mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;AAgBA,kBAEC;
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;AAgBA,kBAEC;AAoBD,sBAwCC;AAED,8BAqBC;AA1FD,MAAM,UAAU,GAAG,cAAuB,CAAC;AAE3C,IAAI,YAAY,GAAG,CAAC,CAAC;AACrB,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,SAAgB,GAAG,CAAC,IAAY;IAC9B,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC;AAID,KAAK,UAAU,mBAAmB;IAChC,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;aAChD,OAAO,EAAE;aACT,WAAW,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,gDAAgD;IAC1D,CAAC;IACD,oDAAoD;IACpD,MAAM,KAAK,GAAG,CAAC,MAAM,OAAO,CAC1B,EAAE,CAAC,EAAE,CAAC,4BAA4B,CAAC,CACpC,CAAC,aAAa,EAAE,CAAQ,CAAC;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,IAAI,sBAAsB,CAAC;IACpE,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC;AAEM,KAAK,UAAU,KAAK,CACzB,aAAqB,EACrB,KAAkB;IAElB,MAAM,OAAO,GAAG;QACd,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC;QAC1B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,E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MAAM,mBAAmB,EAAE,CAAC,CAAC,6CAA6C;QAC1E,MAAM,CAAC,CAAC,CAAC,qDAAqD;IAChE,CAAC;IACD,MAAM,mBAAmB,EAAE,CAAC;AAC9B,CAAC;AAED,SAAgB,SAAS,CAAC,IAAY;IACpC,kEAAkE;IAClE,8DAA8D;IAC9D,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,MAAoC,CAAC;IAC7D,OAAO;QACL,KAAK,CAAC,gBAAgB;YACpB,MAAM,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CACnE,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,qBAAqB,CAAC,CAAS;YACnC,MAAM,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAC/D,MAAM,CAAC,CAAC,CAAC,CACV,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,cAAc,CAAC,GAAG,IAAW;YACjC,MAAM,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAClE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CACrB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/test.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { mount, spy, expectSpy } from
|
|
2
|
-
export { debug } from
|
|
1
|
+
export { mount, spy, expectSpy } from "./mount";
|
|
2
|
+
export { debug } from "./debug";
|
|
3
3
|
//# sourceMappingURL=test.d.ts.map
|
package/dist/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;AAAA,iCAAgD;AAAvC,8FAAA,KAAK,OAAA;AAAE,4FAAA,GAAG,OAAA;AAAE,kGAAA,SAAS,OAAA;AAC9B,iCAAgC;AAAvB,8FAAA,KAAK,OAAA"}
|