@jscutlery/playwright-ct-angular 0.1.3 → 0.2.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/_commonjsHelpers.cjs.js +10 -0
- package/_commonjsHelpers.esm.js +7 -0
- package/hooks.cjs.d.ts +1 -0
- package/hooks.cjs.default.js +1 -0
- package/hooks.cjs.js +32 -0
- package/hooks.cjs.mjs +2 -0
- package/hooks.esm.js +27 -0
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +58987 -0
- package/index.cjs.mjs +2 -0
- package/index.esm.js +58928 -0
- package/package.json +20 -13
- package/register-source.mjs +13 -7
- package/register.cjs.d.ts +2 -0
- package/register.cjs.default.js +1 -0
- package/register.cjs.js +23554 -0
- package/register.cjs.mjs +2 -0
- package/register.esm.js +23552 -0
- package/src/hooks.d.ts +17 -0
- package/src/index.d.ts +18 -1
- package/src/lib/playwright-ct-angular.d.ts +82 -2
- package/src/register.d.ts +17 -0
- package/index.cjs +0 -123
- package/index.js +0 -73
package/src/hooks.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const beforeMount: (callback: any) => void;
|
|
17
|
+
export declare const afterMount: (callback: any) => void;
|
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
export { devices, expect, test } from './lib/playwright-ct-angular';
|
|
2
|
-
export type { ComponentFixtures
|
|
17
|
+
export type { ComponentFixtures } from './lib/playwright-ct-angular';
|
|
18
|
+
import { defineConfig as originalDefineConfig } from '@playwright/experimental-ct-core';
|
|
19
|
+
export declare const defineConfig: typeof originalDefineConfig;
|
|
@@ -8,7 +8,7 @@ export declare const test: playwright.TestType<playwright.PlaywrightTestArgs & p
|
|
|
8
8
|
} & {
|
|
9
9
|
mount: ComponentFixtures['mount'];
|
|
10
10
|
}, playwright.PlaywrightWorkerArgs & playwright.PlaywrightWorkerOptions>;
|
|
11
|
-
export declare const expect: playwright.Expect
|
|
11
|
+
export declare const expect: playwright.Expect<{}>;
|
|
12
12
|
export declare const devices: {
|
|
13
13
|
[key: string]: {
|
|
14
14
|
viewport: playwright.ViewportSize;
|
|
@@ -162,6 +162,22 @@ export declare const devices: {
|
|
|
162
162
|
hasTouch: boolean;
|
|
163
163
|
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
164
164
|
};
|
|
165
|
+
"iPad (gen 5)": {
|
|
166
|
+
viewport: playwright.ViewportSize;
|
|
167
|
+
userAgent: string;
|
|
168
|
+
deviceScaleFactor: number;
|
|
169
|
+
isMobile: boolean;
|
|
170
|
+
hasTouch: boolean;
|
|
171
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
172
|
+
};
|
|
173
|
+
"iPad (gen 5) landscape": {
|
|
174
|
+
viewport: playwright.ViewportSize;
|
|
175
|
+
userAgent: string;
|
|
176
|
+
deviceScaleFactor: number;
|
|
177
|
+
isMobile: boolean;
|
|
178
|
+
hasTouch: boolean;
|
|
179
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
180
|
+
};
|
|
165
181
|
"iPad (gen 6)": {
|
|
166
182
|
viewport: playwright.ViewportSize;
|
|
167
183
|
userAgent: string;
|
|
@@ -546,6 +562,70 @@ export declare const devices: {
|
|
|
546
562
|
hasTouch: boolean;
|
|
547
563
|
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
548
564
|
};
|
|
565
|
+
"iPhone 14": {
|
|
566
|
+
viewport: playwright.ViewportSize;
|
|
567
|
+
userAgent: string;
|
|
568
|
+
deviceScaleFactor: number;
|
|
569
|
+
isMobile: boolean;
|
|
570
|
+
hasTouch: boolean;
|
|
571
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
572
|
+
};
|
|
573
|
+
"iPhone 14 landscape": {
|
|
574
|
+
viewport: playwright.ViewportSize;
|
|
575
|
+
userAgent: string;
|
|
576
|
+
deviceScaleFactor: number;
|
|
577
|
+
isMobile: boolean;
|
|
578
|
+
hasTouch: boolean;
|
|
579
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
580
|
+
};
|
|
581
|
+
"iPhone 14 Plus": {
|
|
582
|
+
viewport: playwright.ViewportSize;
|
|
583
|
+
userAgent: string;
|
|
584
|
+
deviceScaleFactor: number;
|
|
585
|
+
isMobile: boolean;
|
|
586
|
+
hasTouch: boolean;
|
|
587
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
588
|
+
};
|
|
589
|
+
"iPhone 14 Plus landscape": {
|
|
590
|
+
viewport: playwright.ViewportSize;
|
|
591
|
+
userAgent: string;
|
|
592
|
+
deviceScaleFactor: number;
|
|
593
|
+
isMobile: boolean;
|
|
594
|
+
hasTouch: boolean;
|
|
595
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
596
|
+
};
|
|
597
|
+
"iPhone 14 Pro": {
|
|
598
|
+
viewport: playwright.ViewportSize;
|
|
599
|
+
userAgent: string;
|
|
600
|
+
deviceScaleFactor: number;
|
|
601
|
+
isMobile: boolean;
|
|
602
|
+
hasTouch: boolean;
|
|
603
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
604
|
+
};
|
|
605
|
+
"iPhone 14 Pro landscape": {
|
|
606
|
+
viewport: playwright.ViewportSize;
|
|
607
|
+
userAgent: string;
|
|
608
|
+
deviceScaleFactor: number;
|
|
609
|
+
isMobile: boolean;
|
|
610
|
+
hasTouch: boolean;
|
|
611
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
612
|
+
};
|
|
613
|
+
"iPhone 14 Pro Max": {
|
|
614
|
+
viewport: playwright.ViewportSize;
|
|
615
|
+
userAgent: string;
|
|
616
|
+
deviceScaleFactor: number;
|
|
617
|
+
isMobile: boolean;
|
|
618
|
+
hasTouch: boolean;
|
|
619
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
620
|
+
};
|
|
621
|
+
"iPhone 14 Pro Max landscape": {
|
|
622
|
+
viewport: playwright.ViewportSize;
|
|
623
|
+
userAgent: string;
|
|
624
|
+
deviceScaleFactor: number;
|
|
625
|
+
isMobile: boolean;
|
|
626
|
+
hasTouch: boolean;
|
|
627
|
+
defaultBrowserType: "chromium" | "firefox" | "webkit";
|
|
628
|
+
};
|
|
549
629
|
"Kindle Fire HDX": {
|
|
550
630
|
viewport: playwright.ViewportSize;
|
|
551
631
|
userAgent: string;
|
|
@@ -954,7 +1034,7 @@ type Emitted<OBSERVABLE> = OBSERVABLE extends Observable<infer EMITTED> ? EMITTE
|
|
|
954
1034
|
Cf. https://github.com/microsoft/playwright/tree/20957f820d34a53003ab0722fa149c80fedec846/packages/playwright-test/types */
|
|
955
1035
|
declare global {
|
|
956
1036
|
export namespace PlaywrightTest {
|
|
957
|
-
interface Matchers<R
|
|
1037
|
+
interface Matchers<R> {
|
|
958
1038
|
lastCalledWith(...args: Array<unknown>): R;
|
|
959
1039
|
lastReturnedWith(value: unknown): R;
|
|
960
1040
|
not: Matchers<R>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
declare const _default: (components: any) => void;
|
|
17
|
+
export default _default;
|
package/index.cjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var playwright = require('@playwright/test');
|
|
6
|
-
var mount = require('@playwright/test/lib/mount');
|
|
7
|
-
var jestMock = require('jest-mock');
|
|
8
|
-
var path = require('path');
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n["default"] = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var playwright__namespace = /*#__PURE__*/_interopNamespace(playwright);
|
|
29
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
32
|
-
|
|
33
|
-
function _await(value, then, direct) {
|
|
34
|
-
if (direct) {
|
|
35
|
-
return then ? then(value) : value;
|
|
36
|
-
}
|
|
37
|
-
if (!value || !value.then) {
|
|
38
|
-
value = Promise.resolve(value);
|
|
39
|
-
}
|
|
40
|
-
return then ? value.then(then) : value;
|
|
41
|
-
}
|
|
42
|
-
const noop = () => {};
|
|
43
|
-
function _async(f) {
|
|
44
|
-
return function () {
|
|
45
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
46
|
-
args[i] = arguments[i];
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
return Promise.resolve(f.apply(this, args));
|
|
50
|
-
} catch (e) {
|
|
51
|
-
return Promise.reject(e);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
playwright__namespace['_addRunnerPlugin'](() => {
|
|
56
|
-
/* Only fetch upon request to avoid resolution in workers. */
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
58
|
-
const {
|
|
59
|
-
createPlugin
|
|
60
|
-
} = require('@playwright/test/lib/plugins/vitePlugin');
|
|
61
|
-
return createPlugin(path__namespace.join(__dirname, 'register-source.mjs'), noop);
|
|
62
|
-
});
|
|
63
|
-
const mountTest = playwright__namespace.test.extend(mount.fixtures);
|
|
64
|
-
const test = mountTest.extend({
|
|
65
|
-
/**
|
|
66
|
-
* Override mount to return output spies and enjoy type inference.
|
|
67
|
-
* This allows this:
|
|
68
|
-
*
|
|
69
|
-
* const { spies } = mount(..., {outputs: {citySelect: jest.fn()}})
|
|
70
|
-
*
|
|
71
|
-
* instead of this:
|
|
72
|
-
*
|
|
73
|
-
* const citySelectSpy: jest.MockedFunction<(city: string) => void> = jest.fn();
|
|
74
|
-
* mount(..., {outputs: {citySelect: citySelectSpy}});
|
|
75
|
-
*
|
|
76
|
-
* @hack we are willingly not using `async mount(...)` syntax here
|
|
77
|
-
* because it would be transpiled to `_async(function mount() { ... }`
|
|
78
|
-
* by Nx's default rollout config.
|
|
79
|
-
* Playwright dynamically parses the given function so converting
|
|
80
|
-
* async / await to a wrapped function would simply break the library causing
|
|
81
|
-
* a `TypeError: mount is not a function` error.
|
|
82
|
-
*/
|
|
83
|
-
mount({
|
|
84
|
-
mount,
|
|
85
|
-
page
|
|
86
|
-
}, use) {
|
|
87
|
-
return use(_async(function (component, options = {}) {
|
|
88
|
-
/* 1. Create a spy for each output in `spyOutputs`... */
|
|
89
|
-
const spies = options.spyOutputs?.reduce((acc, key) => {
|
|
90
|
-
return {
|
|
91
|
-
...acc,
|
|
92
|
-
[key]: jestMock.fn()
|
|
93
|
-
};
|
|
94
|
-
}, {}) ?? {};
|
|
95
|
-
/* 2. ...then use it as an output... */
|
|
96
|
-
return _await(mount(component, {
|
|
97
|
-
...options,
|
|
98
|
-
outputs: {
|
|
99
|
-
...options.outputs,
|
|
100
|
-
...spies
|
|
101
|
-
}
|
|
102
|
-
}), function () {
|
|
103
|
-
/* Grab a locator to the TestBed's root element.
|
|
104
|
-
* We are loading a fresh new page for each test
|
|
105
|
-
* so the id should always be "root0".
|
|
106
|
-
* Otherwise, we'd have to hack our way and somehow grab all
|
|
107
|
-
* the `#root*`, sort them and grab the last one.
|
|
108
|
-
* As a matter of fact, we can't grab a reference to the fixture. */
|
|
109
|
-
const locator = page.locator('#root0');
|
|
110
|
-
/* Add spies to the returned locator. */
|
|
111
|
-
return Object.assign(locator, {
|
|
112
|
-
spies
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
const expect = playwright__namespace.expect;
|
|
119
|
-
const devices = playwright__namespace.devices;
|
|
120
|
-
|
|
121
|
-
exports.devices = devices;
|
|
122
|
-
exports.expect = expect;
|
|
123
|
-
exports.test = test;
|
package/index.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import * as playwright from '@playwright/test';
|
|
2
|
-
import { fixtures } from '@playwright/test/lib/mount';
|
|
3
|
-
import { fn } from 'jest-mock';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
|
-
const noop = () => {};
|
|
8
|
-
playwright['_addRunnerPlugin'](() => {
|
|
9
|
-
/* Only fetch upon request to avoid resolution in workers. */
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
-
const {
|
|
12
|
-
createPlugin
|
|
13
|
-
} = require('@playwright/test/lib/plugins/vitePlugin');
|
|
14
|
-
return createPlugin(path.join(__dirname, 'register-source.mjs'), noop);
|
|
15
|
-
});
|
|
16
|
-
const mountTest = playwright.test.extend(fixtures);
|
|
17
|
-
const test = mountTest.extend({
|
|
18
|
-
/**
|
|
19
|
-
* Override mount to return output spies and enjoy type inference.
|
|
20
|
-
* This allows this:
|
|
21
|
-
*
|
|
22
|
-
* const { spies } = mount(..., {outputs: {citySelect: jest.fn()}})
|
|
23
|
-
*
|
|
24
|
-
* instead of this:
|
|
25
|
-
*
|
|
26
|
-
* const citySelectSpy: jest.MockedFunction<(city: string) => void> = jest.fn();
|
|
27
|
-
* mount(..., {outputs: {citySelect: citySelectSpy}});
|
|
28
|
-
*
|
|
29
|
-
* @hack we are willingly not using `async mount(...)` syntax here
|
|
30
|
-
* because it would be transpiled to `_async(function mount() { ... }`
|
|
31
|
-
* by Nx's default rollout config.
|
|
32
|
-
* Playwright dynamically parses the given function so converting
|
|
33
|
-
* async / await to a wrapped function would simply break the library causing
|
|
34
|
-
* a `TypeError: mount is not a function` error.
|
|
35
|
-
*/
|
|
36
|
-
mount({
|
|
37
|
-
mount,
|
|
38
|
-
page
|
|
39
|
-
}, use) {
|
|
40
|
-
return use(async (component, options = {}) => {
|
|
41
|
-
/* 1. Create a spy for each output in `spyOutputs`... */
|
|
42
|
-
const spies = options.spyOutputs?.reduce((acc, key) => {
|
|
43
|
-
return {
|
|
44
|
-
...acc,
|
|
45
|
-
[key]: fn()
|
|
46
|
-
};
|
|
47
|
-
}, {}) ?? {};
|
|
48
|
-
/* 2. ...then use it as an output... */
|
|
49
|
-
await mount(component, {
|
|
50
|
-
...options,
|
|
51
|
-
outputs: {
|
|
52
|
-
...options.outputs,
|
|
53
|
-
...spies
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
/* Grab a locator to the TestBed's root element.
|
|
57
|
-
* We are loading a fresh new page for each test
|
|
58
|
-
* so the id should always be "root0".
|
|
59
|
-
* Otherwise, we'd have to hack our way and somehow grab all
|
|
60
|
-
* the `#root*`, sort them and grab the last one.
|
|
61
|
-
* As a matter of fact, we can't grab a reference to the fixture. */
|
|
62
|
-
const locator = page.locator('#root0');
|
|
63
|
-
/* Add spies to the returned locator. */
|
|
64
|
-
return Object.assign(locator, {
|
|
65
|
-
spies
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
const expect = playwright.expect;
|
|
71
|
-
const devices = playwright.devices;
|
|
72
|
-
|
|
73
|
-
export { devices, expect, test };
|