-
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
[Feature] Support for Component Tests in Angular apps #14153
Comments
@jhanink please provide how your see API in ideal world for component testing angular app. |
@mxschmitt @jhanink I thing is a good idea to support angular applications. But let me put some notes. React/vue has a simple API (aka index.html <body>
<app-root></app-root>
// angular runtime
<script src="runtime.js" type="module"></script>
<script src="polyfills.js" type="module"></script>
// compiled app
<script src="main.js" type="module"></script>
</body> main.ts import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { NgModule, Component } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
@Component({
selector: 'app-root',
template:'<span>{{ title }} app is running!</span>'
})
export class AppComponent {
title = 'my-app';
}
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule) |
Does Angular v14 help resolve and make this simpler? With standalone components coming I think this could be similar to the React/Vue/Svelte examples. RFC from Anular for context. |
About the new setup with standalone component angular docs |
That will be great. |
Playwright is so amazing that I want to replace all our e2e tests, including tests in libraries, with Playwright. |
Support for Angular would be great! Cypress has proven it is technically possible, even without standalone components, if I'm not mistaken :). |
Another obstacle is that Playwright transpiles the components with Vite and Angular has no Vite support as far as i know. |
Just released Angular support here: https://github.com/jscutlery/devkit/tree/main/packages/playwright-ct-angular |
I hope PW team will not postpone this feature because of previous comment :) |
While the current implementation only works with Versatile Angular Style. |
I also opened an issue to merge efforts. |
@brandonroberts May I ask if you think it is realistic/desirable to use your Vite plugin for Angular? Saw you said something about it earlier in: analogjs/analog#20 (comment) 😄 |
@sand4rt yes, it's possible to use it. I've tested a working solution with Playwright Component Tests and Angular using the Vite plugin. Supports inline/external styles and constructor DI |
Awesome! Do you still have the solution? Perhaps it can help with the integration if the Playwright team decides to use it? |
I don't have the solution I worked on before, but I remember the steps to get it working. I'll recreate it and push up a repo and we can decide what to do from there |
Here's the repo! https://github.com/brandonroberts/analog-playwright-component-tests Of course it will need more work to override providers and such, but its a start |
Hi all, i'm also building a library for testing Angular components with Playwright due to the absence of @yjaaidi. edit: It is ready for use. If you have any feedback, let me know. @brandon thanks for the repo, managed to integrate your Vite plugin! |
Hi @sand4rt, I was off for a while and catching up now. Also, we are sad to see that there is no credit for our work in your library. |
Which part do you think i should have give credit for? I think that the library i made looks/works nothing like yours right? Edit: Not sure if the Playwright team is focusing on other things, but im still open to collaborate on official support. |
Any news on combining/merging any of the above Angular Component Testing solutions in Playwright? |
@Tallyb was this discussed somewhere? Official support would be great. |
Yes @Tallyb! Actually, you can already opt-in to vite since v16 by replacing That said, this doesn't change things concerning the integration with Playwright etc... as Angular will not expose a vite plugin yet. |
@brandonroberts I think that @Tallyb meant that Angular 17 has official vite support. |
Ahh, ok |
We discussed it in our team meeting. We are interested in landing the Angular support inside the Playwright repository if its like the other frameworks covered with tests/does not depend on a lot of external dependencies. Thanks! |
Perfect! Thank you @mxschmitt! Thank you in advance. |
Awesome! The repo i currently have is like the other frameworks, covered with tests and no external dependencies other than Angular and @brandonroberts's Vite plugin. Will create an PR ASP so we can attack it from multiple angles:) |
Hi all, see the PR above. Curious to hear what you all think! I'll go through it again as well later on this week. |
Cool! Thx @sand4rt! |
How is that support relevant for this discussion/issue? Thanks |
https://playwright.dev/docs/test-components#under-the-hood
|
Its cause Playwright is using vite under the hood thats why Angular is not able to run with it. |
Any update on this, I would be really interested to give it a try in the production? Angular 17 shipped with official esmodule builder, that might help push this issue forward. |
@yjaaidi @pavelfeldman @mxschmitt @sand4rt Kindly requesting an update on this issue. Is this still expected to land somewhere this year? Thank you! |
Hey @Waterstraal! we are working on that 😊 |
@yjaaidi this is awesome, thanks. What is the current status? |
@yjaaidi is there any way to try this out locally ? |
Hey @zargham-leanix, if you just want to play around with it you can clone this https://github.com/yjaaidi/playwright/tree/hello-angular-ct, head to Otherwise, you can |
@yjaaidi I am not able to get it working by following those instructions. I get the following error:
I am supposed to use @playwright/playwright-ct-angular and install it locally in another repo. What do I have to do else to get it to run, I have tried also installing to local playwright in packages but still no luck. |
Hi @muhamedkarajic, it seems that the library was not built first. |
Hi @yjaaidi Just to confirm, this is still waiting for review, merge and release, correct? |
When will this be finally merged? |
And when will this be finally merged? Asked he again. |
+1 |
Hi @yjaaidi
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@playwright%2fplaywright-ct-angular - Not found not sure which step I have missed. |
This has been a fun ride over the past 2.5 years The good news is - it might be ready to ship soon. |
Who are we? Angular devs. What do we want?! Playwright component testing built in for Angular! When do we want it? This year, not next! |
Please support Component Testing for Angular.
In v1.22.0, there is experimental support for react, vue, and svelte Component Tests
The text was updated successfully, but these errors were encountered: