@jscutlery/playwright-ct-angular 0.7.9 → 0.8.1

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@jscutlery/playwright-ct-angular",
3
- "version": "0.7.9",
3
+ "version": "0.8.1",
4
4
  "dependencies": {
5
5
  "@babel/core": "7.23.9",
6
- "@playwright/experimental-ct-core": "1.43.1",
7
- "@playwright/test": "1.43.1"
6
+ "@playwright/experimental-ct-core": "1.47.1",
7
+ "@playwright/test": "1.47.1"
8
8
  },
9
9
  "peerDependencies": {
10
10
  "@angular/compiler": "^16.0.0 || ^17.0.0",
@@ -1,7 +1,6 @@
1
1
  import { Component, reflectComponentType } from '@angular/core';
2
- import { ComponentFixtureAutoDetect, getTestBed, TestBed, TestComponentRenderer } from '@angular/core/testing';
2
+ import { getTestBed, TestBed, TestComponentRenderer } from '@angular/core/testing';
3
3
  import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
4
- import { Subscription } from 'rxjs';
5
4
 
6
5
  /**
7
6
  * @typedef {{type: string} & import('./index').MountTemplateOptions} TemplateInfo
@@ -68,16 +67,17 @@ async function __pwRenderComponent(component, rootElement) {
68
67
  let componentClass;
69
68
 
70
69
  if (__pwIsTemplate(component)) {
71
- const templateInfo = /** @type {TemplateInfo} */(component);
70
+ const templateInfo = /** @type {TemplateInfo} */ (component);
72
71
  componentClass = Component({
73
72
  standalone: true,
74
73
  selector: 'pw-template-component',
75
74
  imports: templateInfo.imports,
76
- template: templateInfo.type
77
- })(class {
78
- });
75
+ template: templateInfo.type,
76
+ })(class {});
79
77
  } else {
80
- componentClass = /** @type {import('@angular/core').Type<unknown>} */(component.type);
78
+ componentClass = /** @type {import('@angular/core').Type<unknown>} */ (
79
+ component.type
80
+ );
81
81
  }
82
82
 
83
83
  const componentMetadata = reflectComponentType(componentClass);
@@ -87,18 +87,19 @@ async function __pwRenderComponent(component, rootElement) {
87
87
  TestBed.configureTestingModule({
88
88
  imports: [componentClass],
89
89
  providers: [
90
- { provide: ComponentFixtureAutoDetect, useValue: true },
91
90
  {
92
91
  provide: TestComponentRenderer,
93
- useValue: new PlaywrightTestComponentRenderer(rootElement)
92
+ useValue: new PlaywrightTestComponentRenderer(rootElement),
94
93
  },
95
- ...component.providers ?? []
96
- ]
94
+ ...(component.providers ?? []),
95
+ ],
97
96
  });
98
97
 
99
98
  const fixture = TestBed.createComponent(componentClass);
100
99
  __pwUpdateProps(fixture, component);
101
100
  __pwUpdateEvents(fixture, component.on);
101
+ /* TODO: switch back to ComponentFixtureAutoDetect once this is fixed https://github.com/angular/angular/issues/57856 */
102
+ fixture.autoDetectChanges();
102
103
 
103
104
  await fixture.whenStable();
104
105
 
package/src/hooks.d.ts CHANGED
@@ -14,11 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { TestBedStatic } from '@angular/core/testing';
17
- import { JsonObject } from '@playwright/experimental-ct-core/types/component';
18
- export declare function beforeMount<HOOKS extends JsonObject>(callback: (params: {
17
+ export declare function beforeMount<HOOKS>(callback: (params: {
19
18
  hooksConfig?: HOOKS;
20
19
  TestBed: TestBedStatic;
21
20
  }) => Promise<void>): void;
22
- export declare function afterMount<HOOKS extends JsonObject>(callback: (params: {
21
+ export declare function afterMount<HOOKS>(callback: (params: {
23
22
  hooksConfig?: HOOKS;
24
23
  }) => Promise<void>): void;
package/src/index.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import type { EnvironmentProviders, EventEmitter, InputSignal, Provider, Type } from '@angular/core';
2
2
  import type { PlaywrightTestConfig, TestType } from '@playwright/experimental-ct-core';
3
3
  import * as playwrightCtCore from '@playwright/experimental-ct-core';
4
- import { JsonObject } from '@playwright/experimental-ct-core/types/component';
5
4
  import * as playwright from '@playwright/test';
6
5
  export type { PlaywrightTestConfig };
7
6
  export { expect, devices } from '@playwright/test';
8
7
  export interface ComponentFixtures {
9
- mount<COMPONENT, HOOKS extends JsonObject>(template: string, options?: MountTemplateOptions<COMPONENT, HOOKS>): Promise<MountResult<COMPONENT>>;
10
- mount<COMPONENT, HOOKS extends JsonObject>(component: Type<COMPONENT>, options?: MountOptions<COMPONENT, HOOKS>): Promise<MountResult<COMPONENT>>;
8
+ mount<COMPONENT, HOOKS>(template: string, options?: MountTemplateOptions<COMPONENT, HOOKS>): Promise<MountResult<COMPONENT>>;
9
+ mount<COMPONENT, HOOKS>(component: Type<COMPONENT>, options?: MountOptions<COMPONENT, HOOKS>): Promise<MountResult<COMPONENT>>;
11
10
  }
12
11
  export interface MountOptions<COMPONENT, HOOKS> {
13
12
  hooksConfig?: HOOKS;
@@ -15,7 +14,7 @@ export interface MountOptions<COMPONENT, HOOKS> {
15
14
  props?: Inputs<COMPONENT>;
16
15
  on?: OutputListeners<COMPONENT>;
17
16
  }
18
- export interface MountTemplateOptions<COMPONENT, HOOKS extends JsonObject> extends MountOptions<COMPONENT, HOOKS> {
17
+ export interface MountTemplateOptions<COMPONENT, HOOKS> extends MountOptions<COMPONENT, HOOKS> {
19
18
  imports?: Type<unknown>[];
20
19
  }
21
20
  export interface MountResult<COMPONENT> extends playwright.Locator {