Protractor E2E Test Seed Database

All we need is an easy explanation of the problem, so here it is.

I haven’t found a good way of doing this so hoping someone has some ideas. Is there any way to seed the database with test data before running a E2E Protractor test?

Do people do this or do they just mock out the back end? Mocking out the back end for me is not an option so would appreciate ideas on how to seed the database. There are a few solutions out there using node but nothing conclusive.

The whole point of E2E testing for my case would be to go to the DB level


How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Being in a NodeJs environment, you can connect to the database directly from Protractor, but I wouldn’t go down that route. You’ll have to update your SQL-setup-script along with your changes to your back-end.

There are other ways:

  1. Use your existing REST facade to populate your database – register a user, connect with another user, etc. If you set-up each of your tests with unique data you would be able to run them simultaneously that way.
  2. Expose to your test environment a special REST point that does all the clearing/setting-up for you between tests.

You can fire REST calls directly from the Protractor environment or use your browser for that.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply