Asked • 07/29/19

What is a good method of storing test data for development and unit testing with angularjs and jasmine?

What is a good method of storing JSON data/objects for development and unit testing with angular and jasmine?I have seen some ways of accomplishing this. However, since I am new to unit testing with JavaScript, I fear going in a bad direction. Here are some examples of what I'd like to accomplish: - Let's say I want to develop my site off a set of test data and and then later on plug it into a database. I figure it would be easier if I am developing and testing off of the same data to start. Maybe all I have to do is reference a js file which has a method in it for returning an array of that data. I don't know what setbacks that might have. - Another example would be that my initial reaction when trying to make a test that uses data was to simply make a $http call to my .json file. I quickly learned I can't do that and would have to mock the data. It seems a pain to have my data both in a unit-test mock as well as a .json file when the current purpose of the data is just for test/dev. I'll have to manage it in two places.

1 Expert Answer

By:

No expert answers yet

Answers can only be accepted by verified, expert tutors.


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.