@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscutlery/playwright-ct-angular",
3
- "version": "0.1.4",
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": "^1.28.0",
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",
@@ -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 { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
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 _componentRegistryMap = new Map();
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 register(components) {
22
+ export function pwRegister(components) {
20
23
  for (const [name, value] of Object.entries(components)) {
21
- _componentRegistryMap.set(name, value);
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 cmpType = _componentRegistryMap.get(component.type);
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(component.options.outputs ?? {})) {
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,2 @@
1
+ export * from "./src/register";
2
+ export { default } from "./src/register";
@@ -0,0 +1 @@
1
+ exports._default = require('./register.cjs.js').default;