Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

More infos/tutorials about Protractor and e2e tests #41369

Closed
MikaStark opened this issue Mar 30, 2021 · 14 comments
Closed

More infos/tutorials about Protractor and e2e tests #41369

MikaStark opened this issue Mar 30, 2021 · 14 comments
Milestone

Comments

@MikaStark
Copy link

MikaStark commented Mar 30, 2021

馃摎 Docs or angular.io bug report

Description

Hello Angular team :). First I want to thank you about your amazing work with Angular ! Today I want to learn how to use e2e tests in my NG projects but it's very hard to found good resources. Your website explains very well how to unit test but not how to e2e test. There are several questions asked on stackoverflow but there are mostly related to angularJS.

馃敩 Minimal Reproduction

What's the affected URL?

https://angular.io/guide/testing

Reproduction Steps

None, there isn't any e2e section

Expected vs Actual Behavior

It will be awsome to have a guide explaining how to write good e2e tests and how to deal with common issues (how to handle authentication, a good style guide, etc.)

@spock123
Copy link

I hope I don't offend anyone but let me give you my advice as a relatively experienced Angular developer:

You should seriously consider dropping Protractor.
My feeling is that the tool will be deprecated in Angular, as soon as the team gets to that.

I would recommend tools like Cypress for end-2-end testing.

I would also consider using Jest for unit testing, as your test runner.

There are plenty of tutorials and walk throughs for both libraries online.

@ngbot ngbot bot added this to the needsTriage milestone Mar 30, 2021
@MikaStark
Copy link
Author

Karma and jasmine are wonderful. I don鈥檛 think jest would be a better solution (as angular supports it out of the box.

Whatever protractor or cypress used (I don鈥檛 recommend it as you need to modify ton of things to make it works), the problem is the lack of official documentation.

Or maybe e2e are not relevant and will eventually be removed in the future ?

@StanislavKharchenko
Copy link

Protractor is default experience for Angular e2e, so, I think, it should be used.
As for documentation - it just wrapper around Selenium, so all selenium documentation (for JS binding) are working with Protractor tests. Also, it have a large community unlike to non-selenium young frameworks (cypress and others) which are quickly born and died in scope of more and more zoo frameworks for JS.
It easy to configure and run and you can find this info at official Protractor web page.
But, sure, it up to you.

@MikaStark
Copy link
Author

As no one is born with the whole knowledge and cannot guess what they don鈥檛 know, it may be great to have at least a little bit of informations about e2e as a lot of companies don鈥檛 use it so it鈥檚 hard to find someone in your environnement that can actually help you to start with testing. You have to learn all by yourself and if you want to change people鈥檚 mind you have to show them the power of what you are learning (angular in my case) but if can鈥檛 find a quick and proper way to learn you cannot do anything.

@StanislavKharchenko
Copy link

@MikaStark This about of not only e2e, IMO :)
But absolutely true if using commercial products/solutions.
In this case - Protractor and Angular are opensource projects, and its documentation and development are rely on resources and common business needs.

@MikaStark
Copy link
Author

Yes but as you can see, protractor as fairly no documentation (open source or not) and the large majority of the community is focused on AngularJS (common guys we are in 2021...). So how can I use it ? Yes I see you can reach html and test a click or assert a attribute/content. Fine.
But what can I do more ? How can I mock the http responses from the backend ? How can I handle with async behaviors ? Etc etc.

testing attributes/event are not enough for a real world project

@spock123
Copy link

spock123 commented Apr 5, 2021

But what can I do more ? How can I mock the http responses from the backend ? How can I handle with async behaviors ?

Why would you mock in E2E tests?

@MikaStark
Copy link
Author

MikaStark commented Apr 5, 2021

Most of my projects are Back offices. If you cannot sign in you cannot do anything. Furthermore, I don鈥檛 want to insert stupid data in preproduction or production database. I鈥檓 front end developer not fullstack so I don鈥檛 care how APIs work, I just want to prove that my front is working. Currently I skip writing e2e tests because of my lack of knowledge about e2e. Also unit tests are not sufficient to ensure that your front is working as expected.

@spock123
Copy link

spock123 commented Apr 5, 2021

@MikaStark I hear you.

The primary issue with Protractor (imho of course) is that it is closely coupled with Angular, and that it was made with Angular1 in mind.

You want to use (again imho of course) a testing library that is frontend tech agnostic, so you can use it for whatever project you might do in the future. If you jump between frameworks it's especially a pain to have to use different libraries for testing.

I would strongly recommend you take a look at Cypress, but there are also other good E2E testing frameworks out there. Cypress is easy to learn, it works with anything and you can mock all you want as well.

Documentation is good, it supports modern standards like async/await, and can run in a browser or command line (so that you can use it for CI stuff).

There are even lots of presentations at ANGULAR conferences where they showcase the use of Cypress.

You should try not to couple your testing tools with your development tools.

Again, these are just my 2cents .. cheers

@StanislavKharchenko
Copy link

@MikaStark You just need to prepare helper which will sign in into your application in the "beforeAll" hook of your test (inject it into your e2e framework-wrapper). And so all your tests will work. It will be more plausible case since e2e involves to use full scenarios of user-application interaction.
Regarding Protractor - yes, initially it was Angular specific, but now it could be used for e2e of any application. Just realize - Protractor is wrapper of selenium-webdriver. For my opinion the good choice is to use selenium-based frameworks, since Selenium is w3c standard with large community and support. You won't have pain in several years if some non-selenium framework (playwright, puppeteer, cypress, omg how many of them) will die.

@MikaStark
Copy link
Author

Anyway you have to deal with 芦聽real聽禄 api that cannot even be considered in my case. I cannot sign in to real APIs for testing.
Maybe that means that e2e tests are not possible for me but it will be sad. My entire projects are unit tested correctly at least but I want to go further.

@spock123
Copy link

spock123 commented Apr 5, 2021

@MikaStark

It sounds like you are looking for Integration testing, not E2E.

@atscott
Copy link
Contributor

atscott commented Apr 5, 2021

Closing - Protractor is being deprecated. See angular/protractor#5502

@atscott atscott closed this as completed Apr 5, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants