1

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks the answer Andres. Is it really a matter of how PRO you want to go though? I mean, for tests to be repeatable, then don't you always have to follow a setup/teardown testing workflow? Thanks for the link (I'm sending some virtual bonus points your way)
I always try to find an existing object or I create a new one if not found. For example: if you are testing that you can create an invoice I find a customer or I create a new customer before testing that I can crate a new invoice for a customer. You just need to make sure that you have all the data dependencies for the test.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.