Cypress is awesome, it is debuggable and it is easy and framework agnostic.
Protractor is flaky for react, while there were multiple attempts to fix them. I think it is a high time to move away from the protractor and start using Cypress
.
There are a lot of discussions happened before especially this one :: https://github.com/jhipster/jhipster-vuejs/pull/399
I have also started the migration in this branch, let us merge both into the main generator and start using Cypress.
cc @nassimerrahoui and @adilabed as they already did it for JHipster Control Center, and nearly finished the work from @clementdessoude in Vue.js blueprint
Then, @sendilkumarn, I would suggest to add Cypress for v6 if possible AND remove Protractor in v7
Then, @sendilkumarn, I would suggest to add Cypress for v6 if possible AND remove Protractor in v7
@pascalgrimaud I like this idea.
@nassimerrahoui, @adilabed & @clementdessoude
Can we start working on this in a branch (likely this one) or any other (instead of duplicating work) ? WDYT?
Can we start working on this in a branch (likely this one) or any other (instead of duplicating work)? WDYT?
I am in favor of concentrating our efforts in this branch https://github.com/sendilkumarn/generator-jhipster/tree/feat/add-cypress, instead of duplicating work.
Then, @sendilkumarn, I would suggest to add Cypress for v6 if possible AND remove Protractor in v7
@pascalgrimaud I like this idea.
@nassimerrahoui, @adilabed & @clementdessoude
Can we start working on this in a branch (likely this one) or any other (instead of duplicating work) ? WDYT?
Yes, it's sounds good to me ! :+1:
As discussed with other members, there is 3 solutions :
Write e2e Cypress tests for each framework like Protactor
Instead of writing e2e tests for each framework, maybe we can use specific attributes to select elements and write common e2e tests for all frameworks including Vuejs blueprint (cf. Cypress documentation for selecting elements)
Create a sub generator for e2e tests
I like the idea of targetting specific attributes for selecting elements. In the end game, it will:
I am all in for targeting specific attributes for selecting elements. But it will be a pain to maintain it across blueprints and an unwanted dependency to carry forward. I am all in if we can find a way around it.
But yeah the main generator should have only one cypress test suite. Let us refactor it. I will create a project in that repo, feel free to pick whatever you like and we will ship it 馃憤 Looking forward to it already.
[Edit] The project is available here
Adding a $100 bug bounty as proposed by @MathieuAA on https://github.com/jhipster/generator-jhipster/issues/11805
hi @sendilkumarn
it seems the Cypress feature has moved forward and we have some test cases available. I would like to help you and @nassimerrahoui @adilabed to complete the feature and to having it in our first v7 release.
WDYT? Have you any idea of what is in to do?
I have checked this branch https://github.com/sendilkumarn/generator-jhipster/tree/feat/add-cypress and this project https://github.com/sendilkumarn/generator-jhipster/projects/1
regards,
EDIT:
After some discussion, this is the plan with @nassimerrahoui and @adilabed
Does it seems a good strategy ?
Finally we move the cypress current work to my JHipster fork because we were not able to rebase from last master version. A draft PR has been open here. We need to:
increasing the bounty as it's a lot of work to achieve it
It's a lot lot lot of work to achieve this, and it was a team work.
So I increase the bounty to 600, and propose this split:
@avdev4j : it was during your full time contribution to JHipster
Hope you're ok with this.
Ping me when you claim the bounty, so I can check and approve.
As the work is achieved, let's close this.
Again, congrats all contributors !
Let's do that! Congrats everyone
@pascalgrimaud : Bounty claimed https://opencollective.com/generator-jhipster/expenses/24786
@pascalgrimaud : Bounty claimed https://opencollective.com/generator-jhipster/expenses/24787
@nassimerrahoui @adilabed : approved
@pascalgrimaud : Bounty claimed https://opencollective.com/generator-jhipster/expenses/24793
@qmonmert : approved
Are there any examples available of how to use cypress with JWT Token?
I can't pass through jhi related stuff because something really cheesy is customized there:
let jwt_token
before(function fetchUser() {
cy.request('POST', '/api/authenticate', {
username: 'user',
password: 'user',
})
.its('body')
.then((res) => {
jwt_token = res.id_token
})
})
beforeEach(function setUser() {
cy.visit('/', {
onBeforeLoad(win) {
win.sessionStorage.setItem('jhi-authenticationtoken', jwt_token)
}
})
})
describe('test', () => {
it('check login works programmatically', () => {
cy.visit('/');
cy.get('.lead').should('have.text', 'Here is microservices catalog');
cy.get('#home-logged-message').should('have.text', 'You are logged in as user "user".')
})
})
First of all I have noticed that instead of local storage session storage is used. But I really don't have any ideas why code above is not working, cause I'm setting id_token exactly as if it will be normal login
https://stackoverflow.com/questions/64714984/jhipster-programatically-login-using-cypress-and-jwt
Most helpful comment
It's a lot lot lot of work to achieve this, and it was a team work.
So I increase the bounty to 600, and propose this split:
@avdev4j : it was during your full time contribution to JHipster
Hope you're ok with this.
Ping me when you claim the bounty, so I can check and approve.
As the work is achieved, let's close this.
Again, congrats all contributors !