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
How to scaffold a component in the test iframe? #1
Comments
I would try using the TestBed to create the components, but even then it doesn't work. There are still a lot of services like the DefaultDomRenderer2 that use the global document object instead of the one available using the DOCUMENT token with the dependency injector. |
Yeah, I am even thinking we need something like this https://glebbahmutov.com/blog/rolling-for-test/ to bundle component over and over and bootstrap it in the test iframe :( |
angular/angular#20229 might be related |
@bahmutov I have the rendering working for elements that use inline templates and styles. When using |
@bahmutov Is there a way to make cypress look for the .spec.ts files in the /src/* directories instead of the cypress/integration directory? |
Is there any chance they will work on angular/angular#20229, is there another way or should I just use Cypress for e2e for now and try to live with a sometimes-working Karma? |
I am searching for a way to get code coverage of my cypress tests for an angular7 project and this solution should be working, I mean when it will be working. Using the angular CLI, if I can mount the application within karma and launch my cypress tests in a spec.ts file, I should get a code coverage report of my e2e tests. Anyone tried this approach ? Thanks a lot |
Since you get the app to start, the problem is to add the respective component dynamically? I assume the dom stays empty because angular does not load the component. We should be able to use the Dynamic Component Loader to achieve that. |
@tobiaseisenschenk shouldn't you already have bootstrapped Angular before you can use that? (I hope not, Karma is bugging me again) |
I'm getting a lot of error messages like these:
Anybody know what I'm doing wrong? |
Fyi guys , this issue was solved by pr #2 |
@geocine so it should work? If so, the readme should be updated. Also, the other Cypress unit test repositories have published npm modules to help you set up your tests. It should be made for Angular too. |
@kayvanbree yes it should, right haven't had the chance to do pull request for the readme. |
Is it ok for you guys now with TestBed implementation ? |
We are ok now, fell free to open an other issue if you have mount problem |
The
mount
function exposed by this package should mount the given component under test in the iframe's window. For example, here is the same code from https://github.com/bahmutov/cypress-angularjs-unit-testIn this repo, I could not find how to scaffold Angular component on demand. See cypress/integration/spec.ts currently. I am trying to put the component into the test iframe and start the app
But so far - no luck.
steps to reproduce
npm install
npx cypress open
starts Cypress GUIspec.ts
file and it will run the testAttention @IgorMinar
The text was updated successfully, but these errors were encountered: