Reputation: 3909
I've recently started getting into Angular (with node.js), and many of the tutorials suggest using Protactor, which looks amazing. One thing has me confused though.
I'm used to tests where test data is built before the test, the test is run, and the data is destroyed.
With protractor it seems you start your server, and have your tests run against that server. In the tutorials I've seen, this server is usually the dev environment (populated by seed data I assume). In my experience, the dev database changes as you play around and tweak your app. Furthermore, a protractor test might delete an object, meaning that for the test to be re-run the object would have to be built again.
When using Protractor, what is the standard practice for creating a test environment with before/after hooks for populate. Bonus points if you can point me to some good resources that answer my question.
Upvotes: 1
Views: 287
Reputation: 8900
Depends an how PRO you want to go. Are you interested in testing in dev only? Do you have other environments? How often do you want to test? I test if different environments. One of them has no data because the database is created before running the tests. Other environments have a lot of data.
I gave a talk in the Angular meetup in NY a few months back:
https://github.com/andresdominguez/protractor-meetup
Take a look at slide 35 of the presentation (the link is in the readme file).
I call the rest api directly to generate data for my tests. You can also run a script before you run your tests to make sure that some objects are present.
Upvotes: 2