@jscutlery/playwright-ct-angular 0.1.4 → 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.js +58916 -23
- package/index.esm.js +58881 -20
- package/package.json +12 -2
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscutlery/playwright-ct-angular",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"jest-mock": "^28.1.3",
|
|
6
6
|
"rxjs": "^7.5.7",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@angular/core": "*",
|
|
11
11
|
"@angular/platform-browser": "*",
|
|
12
12
|
"@angular/platform-browser-dynamic": "*",
|
|
13
|
-
"@playwright/test": "
|
|
13
|
+
"@playwright/test": ">=1.39.0",
|
|
14
14
|
"tslib": "*"
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"module": "./index.esm.js",
|
|
20
20
|
"import": "./index.cjs.mjs",
|
|
21
21
|
"default": "./index.cjs.js"
|
|
22
|
+
},
|
|
23
|
+
"./hooks": {
|
|
24
|
+
"module": "./hooks.esm.js",
|
|
25
|
+
"import": "./hooks.cjs.mjs",
|
|
26
|
+
"default": "./hooks.cjs.js"
|
|
27
|
+
},
|
|
28
|
+
"./register": {
|
|
29
|
+
"module": "./register.esm.js",
|
|
30
|
+
"import": "./register.cjs.mjs",
|
|
31
|
+
"default": "./register.cjs.js"
|
|
22
32
|
}
|
|
23
33
|
},
|
|
24
34
|
"module": "./index.esm.js",
|
package/register-source.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import '@angular/compiler';
|
|
2
2
|
import 'zone.js';
|
|
3
3
|
import { getTestBed, TestBed } from '@angular/core/testing';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BrowserDynamicTestingModule,
|
|
6
|
+
platformBrowserDynamicTesting,
|
|
7
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
5
8
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
6
9
|
import { Subscription } from 'rxjs';
|
|
7
10
|
|
|
8
|
-
const
|
|
11
|
+
const _componentLoaderMap = new Map();
|
|
9
12
|
|
|
10
13
|
getTestBed().initTestEnvironment(
|
|
11
14
|
BrowserDynamicTestingModule,
|
|
@@ -16,9 +19,9 @@ getTestBed().initTestEnvironment(
|
|
|
16
19
|
* This is the function used by Playwright CT to map each component to its symbol.
|
|
17
20
|
* The key here is a slug generated by Playwright CT based on the component's module path + component's name.
|
|
18
21
|
*/
|
|
19
|
-
function
|
|
22
|
+
export function pwRegister(components) {
|
|
20
23
|
for (const [name, value] of Object.entries(components)) {
|
|
21
|
-
|
|
24
|
+
_componentLoaderMap.set(name, value);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -29,12 +32,13 @@ function register(components) {
|
|
|
29
32
|
let subscription;
|
|
30
33
|
|
|
31
34
|
globalThis.playwrightMount = async (component, rootElement, hooksConfig) => {
|
|
32
|
-
const
|
|
35
|
+
const loader = _componentLoaderMap.get(component.type);
|
|
36
|
+
const cmpType = await loader();
|
|
33
37
|
|
|
34
38
|
subscription = new Subscription();
|
|
35
39
|
|
|
36
40
|
TestBed.configureTestingModule({
|
|
37
|
-
imports: [BrowserAnimationsModule]
|
|
41
|
+
imports: [BrowserAnimationsModule],
|
|
38
42
|
});
|
|
39
43
|
const fixture = TestBed.createComponent(cmpType);
|
|
40
44
|
|
|
@@ -44,7 +48,9 @@ globalThis.playwrightMount = async (component, rootElement, hooksConfig) => {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/* Subscribe to outputs. */
|
|
47
|
-
for (const [name, callback] of Object.entries(
|
|
51
|
+
for (const [name, callback] of Object.entries(
|
|
52
|
+
component.options.outputs ?? {}
|
|
53
|
+
)) {
|
|
48
54
|
subscription.add(fixture.componentInstance[name].subscribe(callback));
|
|
49
55
|
}
|
|
50
56
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./register.cjs.js').default;
|