@testspectra/matchers 1.1.8-rc.2 → 1.1.8-rc.21
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/dist/__tests__/matchers.test.js +8 -0
- package/dist/runner/collection.d.ts +4 -16
- package/dist/runner/collection.js +12 -24
- package/dist/runner/single.d.ts +2 -28
- package/dist/runner/single.js +36 -55
- package/dist/spectra.d.ts +3 -3
- package/dist/spectra.js +3 -3
- package/package.json +10 -11
- package/src/contract.ts +223 -223
- package/src/proto.ts +35 -35
- package/src/runtime/assertions.ts +454 -453
- package/src/runtime/element_actions.ts +178 -178
- package/src/runtime/element_proxy.ts +200 -200
- package/src/runtime/element_state.ts +94 -94
- package/src/runtime/spectra.ts +110 -110
- package/src/types.ts +1648 -1648
- package/testspectra-matchers-1.1.8-rc.21.tgz +0 -0
- package/tsconfig.json +17 -17
- package/dist/semantic.d.ts +0 -11
- package/dist/semantic.js +0 -141
package/src/runtime/spectra.ts
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds the global `Spectra` automation object.
|
|
3
|
-
*
|
|
4
|
-
* All static actions delegate to the bound `PlatformDriverBridge` (browser/navigation/gestures/
|
|
5
|
-
* network) or to element proxies (element actions). No platform branching here.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type {
|
|
9
|
-
ClickOptions,
|
|
10
|
-
ElementTarget,
|
|
11
|
-
KeyOption,
|
|
12
|
-
LongPressOptions,
|
|
13
|
-
MockInterceptHandle,
|
|
14
|
-
ScrollOptions,
|
|
15
|
-
SpectraStatic,
|
|
16
|
-
SwipeOptions,
|
|
17
|
-
TypeOptions,
|
|
18
|
-
} from '@testspectra/matchers';
|
|
19
|
-
|
|
20
|
-
export function buildSpectra(): SpectraStatic {
|
|
21
|
-
const driver = () => globalThis.__TS_RUNTIME__.activeDriver!;
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
get: (target: ElementTarget) => globalThis.__TS_RUNTIME__.resolveTargetProxy!(target),
|
|
25
|
-
getAll: (selector: string) => globalThis.__TS_RUNTIME__.createCollectionProxy!(selector),
|
|
26
|
-
navigate: (url: string) => driver().navigate(url),
|
|
27
|
-
back: () => driver().back(),
|
|
28
|
-
forward: () => driver().forward(),
|
|
29
|
-
refresh: () => driver().refresh(),
|
|
30
|
-
setViewport: (width: number, height: number) => driver().setViewport(width, height),
|
|
31
|
-
wait: (ms: number) => driver().pause(ms),
|
|
32
|
-
click: async (target: ElementTarget, _textOrOptions?: string | ClickOptions) => {
|
|
33
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
34
|
-
await el.click();
|
|
35
|
-
},
|
|
36
|
-
doubleClick: async (target: ElementTarget) => {
|
|
37
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
38
|
-
await el.doubleClick();
|
|
39
|
-
},
|
|
40
|
-
rightClick: async (target: ElementTarget) => {
|
|
41
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
42
|
-
await el.rightClick();
|
|
43
|
-
},
|
|
44
|
-
type: async (target: ElementTarget, text: string, options?: TypeOptions) => {
|
|
45
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
46
|
-
await el.type(text, options);
|
|
47
|
-
},
|
|
48
|
-
clear: async (target: ElementTarget) => {
|
|
49
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
50
|
-
await el.clear();
|
|
51
|
-
},
|
|
52
|
-
select: async (target: ElementTarget, option: string) => {
|
|
53
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
54
|
-
await el.select(option);
|
|
55
|
-
},
|
|
56
|
-
hover: async (target: ElementTarget) => {
|
|
57
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
58
|
-
await el.hover();
|
|
59
|
-
},
|
|
60
|
-
focus: async (target: ElementTarget) => {
|
|
61
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
62
|
-
await el.focus();
|
|
63
|
-
},
|
|
64
|
-
dragDrop: async (source: ElementTarget, destination: ElementTarget) => {
|
|
65
|
-
const srcEl = globalThis.__TS_RUNTIME__.resolveTargetProxy!(source);
|
|
66
|
-
await srcEl.dragDrop(destination);
|
|
67
|
-
},
|
|
68
|
-
scrollIntoView: async (target: ElementTarget) => {
|
|
69
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
70
|
-
await el.scrollIntoView();
|
|
71
|
-
},
|
|
72
|
-
scroll: async (options?: ScrollOptions) => {
|
|
73
|
-
await driver().scroll(options);
|
|
74
|
-
},
|
|
75
|
-
swipe: async (options: SwipeOptions) => {
|
|
76
|
-
await driver().swipe(options);
|
|
77
|
-
},
|
|
78
|
-
longPress: async (target: ElementTarget, options?: LongPressOptions | number) => {
|
|
79
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
80
|
-
await el.longPress(options);
|
|
81
|
-
},
|
|
82
|
-
pressKey: async (key: KeyOption | string) => {
|
|
83
|
-
await driver().pressKey(key);
|
|
84
|
-
},
|
|
85
|
-
grantPermission: async (name: string) => {
|
|
86
|
-
await driver().grantPermission(name);
|
|
87
|
-
},
|
|
88
|
-
waitForElement: async (target: ElementTarget, timeoutMs?: number) => {
|
|
89
|
-
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
90
|
-
await el.waitForElement(timeoutMs);
|
|
91
|
-
},
|
|
92
|
-
intercept: async (
|
|
93
|
-
patternOrOptions: any,
|
|
94
|
-
maybeMethodOrHandler?: any,
|
|
95
|
-
maybeFixture?: any,
|
|
96
|
-
maybeOptions?: any,
|
|
97
|
-
): Promise<MockInterceptHandle> => {
|
|
98
|
-
return await driver().intercept(patternOrOptions, maybeMethodOrHandler, maybeFixture, maybeOptions);
|
|
99
|
-
},
|
|
100
|
-
clearMocks: () => {
|
|
101
|
-
driver().clearMocks();
|
|
102
|
-
},
|
|
103
|
-
get browser() {
|
|
104
|
-
return driver();
|
|
105
|
-
},
|
|
106
|
-
env: (globalThis.__TS_RUNTIME__.config.environmentVariables || {}) as SpectraEnv,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
globalThis.__TS_RUNTIME__.buildSpectra = buildSpectra;
|
|
1
|
+
/**
|
|
2
|
+
* Builds the global `Spectra` automation object.
|
|
3
|
+
*
|
|
4
|
+
* All static actions delegate to the bound `PlatformDriverBridge` (browser/navigation/gestures/
|
|
5
|
+
* network) or to element proxies (element actions). No platform branching here.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
ClickOptions,
|
|
10
|
+
ElementTarget,
|
|
11
|
+
KeyOption,
|
|
12
|
+
LongPressOptions,
|
|
13
|
+
MockInterceptHandle,
|
|
14
|
+
ScrollOptions,
|
|
15
|
+
SpectraStatic,
|
|
16
|
+
SwipeOptions,
|
|
17
|
+
TypeOptions,
|
|
18
|
+
} from '@testspectra/matchers';
|
|
19
|
+
|
|
20
|
+
export function buildSpectra(): SpectraStatic {
|
|
21
|
+
const driver = () => globalThis.__TS_RUNTIME__.activeDriver!;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
get: (target: ElementTarget) => globalThis.__TS_RUNTIME__.resolveTargetProxy!(target),
|
|
25
|
+
getAll: (selector: string) => globalThis.__TS_RUNTIME__.createCollectionProxy!(selector),
|
|
26
|
+
navigate: (url: string) => driver().navigate(url),
|
|
27
|
+
back: () => driver().back(),
|
|
28
|
+
forward: () => driver().forward(),
|
|
29
|
+
refresh: () => driver().refresh(),
|
|
30
|
+
setViewport: (width: number, height: number) => driver().setViewport(width, height),
|
|
31
|
+
wait: (ms: number) => driver().pause(ms),
|
|
32
|
+
click: async (target: ElementTarget, _textOrOptions?: string | ClickOptions) => {
|
|
33
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
34
|
+
await el.click();
|
|
35
|
+
},
|
|
36
|
+
doubleClick: async (target: ElementTarget) => {
|
|
37
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
38
|
+
await el.doubleClick();
|
|
39
|
+
},
|
|
40
|
+
rightClick: async (target: ElementTarget) => {
|
|
41
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
42
|
+
await el.rightClick();
|
|
43
|
+
},
|
|
44
|
+
type: async (target: ElementTarget, text: string, options?: TypeOptions) => {
|
|
45
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
46
|
+
await el.type(text, options);
|
|
47
|
+
},
|
|
48
|
+
clear: async (target: ElementTarget) => {
|
|
49
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
50
|
+
await el.clear();
|
|
51
|
+
},
|
|
52
|
+
select: async (target: ElementTarget, option: string) => {
|
|
53
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
54
|
+
await el.select(option);
|
|
55
|
+
},
|
|
56
|
+
hover: async (target: ElementTarget) => {
|
|
57
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
58
|
+
await el.hover();
|
|
59
|
+
},
|
|
60
|
+
focus: async (target: ElementTarget) => {
|
|
61
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
62
|
+
await el.focus();
|
|
63
|
+
},
|
|
64
|
+
dragDrop: async (source: ElementTarget, destination: ElementTarget) => {
|
|
65
|
+
const srcEl = globalThis.__TS_RUNTIME__.resolveTargetProxy!(source);
|
|
66
|
+
await srcEl.dragDrop(destination);
|
|
67
|
+
},
|
|
68
|
+
scrollIntoView: async (target: ElementTarget) => {
|
|
69
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
70
|
+
await el.scrollIntoView();
|
|
71
|
+
},
|
|
72
|
+
scroll: async (options?: ScrollOptions) => {
|
|
73
|
+
await driver().scroll(options);
|
|
74
|
+
},
|
|
75
|
+
swipe: async (options: SwipeOptions) => {
|
|
76
|
+
await driver().swipe(options);
|
|
77
|
+
},
|
|
78
|
+
longPress: async (target: ElementTarget, options?: LongPressOptions | number) => {
|
|
79
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
80
|
+
await el.longPress(options);
|
|
81
|
+
},
|
|
82
|
+
pressKey: async (key: KeyOption | string) => {
|
|
83
|
+
await driver().pressKey(key);
|
|
84
|
+
},
|
|
85
|
+
grantPermission: async (name: string) => {
|
|
86
|
+
await driver().grantPermission(name);
|
|
87
|
+
},
|
|
88
|
+
waitForElement: async (target: ElementTarget, timeoutMs?: number) => {
|
|
89
|
+
const el = globalThis.__TS_RUNTIME__.resolveTargetProxy!(target);
|
|
90
|
+
await el.waitForElement(timeoutMs);
|
|
91
|
+
},
|
|
92
|
+
intercept: async (
|
|
93
|
+
patternOrOptions: any,
|
|
94
|
+
maybeMethodOrHandler?: any,
|
|
95
|
+
maybeFixture?: any,
|
|
96
|
+
maybeOptions?: any,
|
|
97
|
+
): Promise<MockInterceptHandle> => {
|
|
98
|
+
return await driver().intercept(patternOrOptions, maybeMethodOrHandler, maybeFixture, maybeOptions);
|
|
99
|
+
},
|
|
100
|
+
clearMocks: () => {
|
|
101
|
+
driver().clearMocks();
|
|
102
|
+
},
|
|
103
|
+
get browser() {
|
|
104
|
+
return driver();
|
|
105
|
+
},
|
|
106
|
+
env: (globalThis.__TS_RUNTIME__.config.environmentVariables || {}) as SpectraEnv,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
globalThis.__TS_RUNTIME__.buildSpectra = buildSpectra;
|