-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Component Testing on Angular components #15903
Comments
+1 Also, how does this - https://github.com/bahmutov/cypress-angular-unit-test - relate to the new component testing feature? |
I think we should be able to migrate the angular-unit-test plugin to the cypress monorepo relatively easily. We will discuss and investigate this soon. |
Thanks @lmiller1990 we look forward to the PR. |
I didn't realize some other work was happening around Angular - my bad. Either way, Angular support is a thing we can and will have! |
Please! This would be amazing to have! |
I see @yjaaidi has a test-util that can potentially be used for component testing? Unless there is something else specifically, but this is the repo that he mentioned under bahmutov/cypress-angular-unit-test#248: https://github.com/jscutlery/test-utils/tree/main/packages/cypress-mount: |
Hey 👋!
We are working with both Cypress & Angular teams on the last two items. We hope that we will be able to merge the effort in the Cypress monorepo. @jscutlery/cypress-mount will probably be maintained as an adapter if the interface of the merged effort changes |
Does the cypress-mount package work with Cypress 7.0? I tried using it, but I think the changes in 7.0 mean that cypress-mount would need some work. Is this right, or am I missing something? |
Let me just say that hearing you say that there's a plan to support Angular is such a huge relief to me. It took me about a week to integrate Cypress component testing pre 7.0.0 into my project and that's just to get it working! Then when 7.0.0 released I found it broke everything and it wasn't a simple fix. I was so distraught. |
Everyone is used to living in React's shadow 💀 Anyway with the first class Component Testing runner, sunny days are ahead for all ⚡ |
Amazing job! Thanks! |
This PR is adding a package, Looking forward to giving the Angular integration a go! I don't know much about Angular, but I made a small app once, it was pretty nice. |
Thanks @lmiller1990 it would be great if cypress could mount the components the same way Storybook does it with the global styles included under the assets folder. |
Yes, we should definitely have something similar to |
Latest work for this is here: https://github.com/bahmutov/cypress-angular-unit-test/pull/412/files |
We made some experiements on |
EXCITING TIMES!!!! 😃 @yjaaidi |
🎉 cypress-angular-unit-test 3.8.0 is released for Cypress component testting v7 !!! 🎉 https://github.com/bahmutov/cypress-angular-unit-test/releases/tag/v3.8.0 |
💯 Wunderbar. Next steps will be to remove the build tooling that is unrelated to Circle CI. There are a lot of GH actions, etc in the current PR #16434 I'm going to comment on that PR right now with merge criteria. |
@LeJeanbono I just wanted to let you know that I have an Angular 11 app using Material and thanks to your 3.8.0 release, I can now do component unit tests on Cypress version 7.2.0. Thanks so much!! I did have a couple of notes however:
import * as webpackConfig from './webpack.config';
const { startDevServer } = require('@cypress/webpack-dev-server');
/**
* @param on is used to hook into various events Cypress emits
* @param config is the resolved Cypress config
*/
module.exports = (on: any, config: any) => {
// remove the 'default' key to avoid WebpackOptionsValidationError
delete webpackConfig['default'];
on('dev-server:start', (options) =>
startDevServer({
options,
webpackConfig,
}),
);
return config;
};
// tsconfig.json
{
"paths": {
"@customPath/*": ["./src/app/customPath/*"]
}
} // webpack.config.ts
module.exports = {
resolve: {
alias: {
"@customPath": path.resolve('./src/app/customPath'),
}
}
}
Idk if these issues were unique to me becuase of how something in our project was set up, but I thought I would consolidate all of the extra little "gotchas" I ran into here in case someone else finds themselves in the same situation :) |
Thanks for the list of gotchas. I think the last two are pretty common in general (webpack and tsconfig do not know about each other, so you need to duplicate the aliases). As for the first one, I wonder what happens if you do Either way, great to see you got it working! I hope we can find a smoother way to integrate other than just duplicating the webpack configuration, but for now it seems like that's the only way to configure Angular with Cypress. |
Hey everyone! We, @jscutlery (@edbzn & me), just released @jscutlery/cypress-angular. It is Cypress 7 compatible and provides: ❤️ Feedback, ideas & contributions are welcome! |
@yjaaidi is there a temp workaround for getting angular components to render the same way it would in production, when doing an |
Any update on this being pulled into the cypress monorepo? |
@jordanpowell88 was working on this most recently, here's the PR: #20042 We are focusing on hitting Cypress v10 with improved support for component testing in general (currently alpha), when that lands we should be more easily able to iterate and support additional frameworks. My understanding is it's already possible to use Angular w/ Cypress Component Testing as a third party project: #15903 (comment), but we will hopefully have first class support soon, too. |
I just learned about component testing, and was wondering if it executed faster than regular e2e tests? Our tests take about 45min - 1hr to run without using component testing. |
It will depend, but generally yes - most e2e tests will create a fully blown server, database etc, component tests tend to be (mostly) browser only and much more lightweight + faster. They aren't a replacement for e2e tests, but definitely can be used along side them, so you don't need to spin up a full app to test every state of every component. |
Since cypress 10 is now released, it would be appreciated if angular component testing support receives some attention again. It really should get a own section "Angular Component Testing" in the guides also https://docs.cypress.io/guides/component-testing/writing-your-first-component-test#Component-vs-End-to-End-in-a-Nutshell |
Yep, agreed, we are working on it (@jordanpowell88 mainly). I'll find out more and let you know, there should be branch you can follow and try out. |
Just wanted to let everyone here know that I've been actively working on this. If you want to play around with the POC feel free to checkout my repo: https://github.com/jordanpowell88/angular-ct |
Any news on this? It seems that there has been no progress in the last 2 months (looking at the commits here https://github.com/jordanpowell88/angular-ct/commits/master). However there seems to be recent activity (-4 days) in a branch that aims to add angular ct schematics (however I don't see any value in the schematics if ct testing support is not ready yet): https://github.com/cypress-io/cypress/compare/feat-add-angular-ct-schematic |
It will be released in 10.5 |
Closing this as it is a duplicate issue of #22819 |
What would you like?
I would like Cypress to add support for component testing Angular components. I feel it is just as important as the supported React/Vue.js frameworks.
Why is this needed?
To test on a component level.
The text was updated successfully, but these errors were encountered: