Protractor: manage database state during test runs

Created on 31 Dec 2014  路  4Comments  路  Source: angular/protractor

We want to do E2E testing between our Angular app and our API using Protractor. We can't figure out how to setup the database before and between tests.

We want the ability to add a specific record or records before a given test runs and then reset the database after that test runs.

We've investigated using this mostly Ruby stack: RSpec, Database Cleaner, FactoryGirl, Capybara, and Poltergeist. This works OK but is infested with sleep calls. We'd therefore prefer to use Protractor.

Unfortunately, it doesn't seem that Protractor has any capabilities to manage database state. Does anyone have any advice on how to handle this?

question

Most helpful comment

@kris-luminar I clear and fill the database inside a beforeEach statement that it is global. Hope this help.

All 4 comments

It completely depends on what database you're using and what its API is. Protractor tests are run using Node, so if you can use Node to interact with your database in any way just do that. You'll probably want to do it in a setup file that you put in the config as onPrepare.

Thanks @juliemr . We are using Postgres and Node.

This isn't the best forum to answer questions about Postgres, so I'm going to go ahead and close this issue - sounds like you just need to use add an onPrepare file and use node-postgres or something similar.

@kris-luminar I clear and fill the database inside a beforeEach statement that it is global. Hope this help.

Was this page helpful?
0 / 5 - 0 ratings