-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ct): angular component testing #27783
Closed
Closed
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8a8c1ff
feat(ct): angular component testing
sand4rt 81f8151
test(ct): test non-event-emitter outputs
yjaaidi 8844ebd
test(ct): test output listener replacement
yjaaidi bd67f8b
feat(ct): support non-event-emitter outputs
yjaaidi b880cc9
fix(ct): angular source maps
sand4rt c39aa49
docs(ct): angular
sand4rt 5f76257
chore(ct): new angular logo
sand4rt 2aa4597
Add support for Angular 17 (#5)
yjaaidi a3dc1f9
chore: remove docs until official release
sand4rt 4747ae0
chore: bump to playwright 1.45.0-next
sand4rt 2894096
fix(ct): linting issue
sand4rt 7f4626a
chore: fix ci and formatting
sand4rt a018a27
fix(ct): angular unused file
sand4rt 666a18d
core: remove duplicate test
sand4rt cc7e9b8
fix(ct): remove zone.js from angular-ct (#8)
yjaaidi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
**/* | ||
|
||
!README.md | ||
!LICENSE | ||
!cli.js | ||
!register.d.ts | ||
!register.mjs | ||
!registerSource.mjs | ||
!index.d.ts | ||
!index.js | ||
!hooks.d.ts | ||
!hooks.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
> **BEWARE** This package is EXPERIMENTAL and does not respect semver. | ||
|
||
Read more at https://playwright.dev/docs/test-components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const { program } = require('@playwright/experimental-ct-core/lib/program'); | ||
|
||
program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { TestBedStatic } from '@angular/core/testing'; | ||
import type { JsonObject } from '@playwright/experimental-ct-core/types/component'; | ||
|
||
export declare function beforeMount<HooksConfig extends JsonObject>( | ||
callback: (params: { hooksConfig?: HooksConfig, TestBed: TestBedStatic }) => Promise<void> | ||
): void; | ||
export declare function afterMount<HooksConfig extends JsonObject>( | ||
callback: (params: { hooksConfig?: HooksConfig }) => Promise<void> | ||
): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const __pw_hooks_before_mount = []; | ||
const __pw_hooks_after_mount = []; | ||
|
||
window.__pw_hooks_before_mount = __pw_hooks_before_mount; | ||
window.__pw_hooks_after_mount = __pw_hooks_after_mount; | ||
|
||
export const beforeMount = callback => { | ||
__pw_hooks_before_mount.push(callback); | ||
}; | ||
|
||
export const afterMount = callback => { | ||
__pw_hooks_after_mount.push(callback); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { Locator } from 'playwright/test'; | ||
import type { JsonObject } from '@playwright/experimental-ct-core/types/component'; | ||
import type { TestType } from '@playwright/experimental-ct-core'; | ||
import type { Type } from '@angular/core'; | ||
|
||
export type ComponentEvents = Record<string, Function>; | ||
|
||
export interface MountOptions<HooksConfig extends JsonObject, Component> { | ||
props?: Partial<Component> | Record<string, unknown>, // TODO: filter props and handle signals | ||
on?: ComponentEvents; | ||
hooksConfig?: HooksConfig; | ||
} | ||
|
||
export interface MountResult<Component> extends Locator { | ||
unmount(): Promise<void>; | ||
update(options: { | ||
props?: Partial<Component>, | ||
on?: Partial<ComponentEvents>, | ||
}): Promise<void>; | ||
} | ||
|
||
export const test: TestType<{ | ||
mount<HooksConfig extends JsonObject, Component = unknown>( | ||
component: Type<Component>, | ||
options?: MountOptions<HooksConfig, Component> | ||
): Promise<MountResult<Component>>; | ||
}>; | ||
|
||
export { defineConfig, PlaywrightTestConfig } from '@playwright/experimental-ct-core'; | ||
export { expect, devices } from 'playwright/test'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand a bit on the TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types are quite loose now while they should be stricter. @yjaaidi you already made something for this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly!
We implemented this here https://github.com/jscutlery/devkit/blob/353aeb322fecad64ba8b3667613deca537adb743/packages/playwright-ct-angular/src/index.ts#L35
IMHO, it's better if we add this later in a distinct PR to reduce the surface of this PR.