jeudi 30 août 2018

Keep application-state in protractor E2E tests

I have a big application written with angular and I currently try to introduce e2e testing. Is it possible to keep the "state" of the application and not write a single it statement. So at the my tests look like this:

describe('Dashboard', () => {
  beforeEach(() => {
    // do login
  });

  it('should navigate to X', () => {
    // click on navigation
    // test if component X is open
  });

  it('should navigate to Y', () => {
    // click on navigation
    // test if component Y is open
  });

  it('should navigate to Z', () => {
    // click on navigation
    // test if component Z is open
  });
});

In the beforeEach the test logs into the app (so the dashboard is open). In every test, first there is a click on a navigation-element and I test if the according component opens.

What I want is that I don't have to do the login in each beforeEach in any of my tests. So the tests keep the state of the application and that the application running all the time as in "real usage" and not restart after every test. Is the only possibility for this to write a single it statement like this:

describe('Application', () => {
    // do login

    // should navigate to X
    // click on navigation
    // test if component X is open

    // should navigate to Y
    // click on navigation
    // test if component Y is open

    // should navigate to Z
    // click on navigation
    // test if component Z is open
  });
});

Maybe I understand the e2e test wrong and I should use another sort of tests for this. If thats the case, could you give me some advice for a testing-framework which can be used for angular?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire