Mocking Data Calls
Allow for Breeze's data service calls to be able to be overridden with mock data calls, so data can be seen without needs to make actual ajax calls for designing and testing. Similar to amplify's model and using mockJSON with it.
As of version 0.70.1, Breeze supports the ability to completely customize or replace any Ajax communication between the Breeze client and the web service on the server.
The Breeze documentation on our Ajax support is still in progress, but hopefully the following will get you started:
Ward Bell commented
Great idea. We already have plugging the AJAX call on our backlog because we don't want a dependency on jQuery. We'll get it in there "soon" so stay tuned.
Meanwhile, there is another faking option that is backed into Breeze and that I use all the time for my tests. I simply create new entities and attach them to the EntityManager as "existing entities". In test mode, I add the local cache fetch strategy which turns any query into a cache-only query. The structure remains async (you get a promise back), but it's actually executed synchronously against the cache and does not attempt a server trip.
You add such a strategy with this clause (a bit of a mouthful):
"query = query.using(entityModel.FetchStrategy.FromLocalCache)"
Your calling code (e.g., ViewModel) doesn't know that you are making this switch.
Now simulating Save is a little trickier ... as it would be if you're trying to mock that with amplify ... because the caller is expecting the entities to be different after the save returns successfully (e.g., new keys assigned, change-state is "unmodified" etc.). Amplify won't do that automatically either. It's actually pretty easy to fake with a little Breeze code if you need it.
None of this diminishes the value of this suggestion; we'll get to it.