1

I do have 2 *.e2e-spec.ts files for an E2E testing. So now I would like to share data between these files.

e.g. an email which is used for a signup signup-e2e.spec.ts and I would like to use it for login in the login-e2e-spec.ts

I have been searching and this is the only article I found, but it seems to be old and to be honest, it's a kind of not 100% clear for me.

Any hint oder idea please?

  • 1
    It is not good practice to share data between tests.Aim to make the tests independent of each other. – Vishal Aggarwal Mar 4 '18 at 20:07
  • Data dependency between tests cause the flakyness in the tests. – Vishal Aggarwal Mar 4 '18 at 20:17
  • @VishalAggarwal: to be honest, I really was thinking about this kind of issue - but for instance, if I do have a register page and login page. Don't you think it would make sense running a test for registration reg-e2e.spec.ts and then passing the user credentials to the login test file *login-e2e.spec.ts. Otherwise I have to run registration test alone, and then run test for login but including registration again before login in one file. – k.vincent Mar 5 '18 at 7:45
  • And what if registration fails,then login will also fail , right? – Vishal Aggarwal Mar 5 '18 at 9:04
  • Yes, that's true! – k.vincent Mar 5 '18 at 9:16
1

In order to be DRY, you would need data files: This article may help setting up data files and using them across Protactor E2E Tests.

1

Read static data from external json files to reuse across multiple tests however any dynamic data (which may change state during test runs) avoid reusing across tests as it may make your tests brittle and flaky. Sample json file:

{ 
"appURL": "http://testApp123.com",  
"Username": "testUser@domain.com",  
"Password": "testPassword",
 "Title":"SUT"
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.