![]() In order to record responses, or simply just let your e2e tests proxy to a real server then you can pass the prism mode into the e2e task in the same fashion as with the grunt serve task grunt e2e:record The e2e task is configured to mock responses when you run `grunt e2e`. For any other content-type it will fallback to a string.Īn example response file in prism-sample-project. If the response type happens to be JSON then it will pretty print it in the response file for easier inspection. Prism will capture the request URL, including query parameters, content type, HTTP response status, and the data itself. In record mode prism acts as proxy, but with the added capability of recording the proxied response. While in record mode you perform all the actions that trigger requests to your backend that you would like to record responses for. It operates in much the same manner as grunt-connect-proxy, in fact by default it works the exact same way and lets you proxy traffic through your development connect server. Prism works by adding a middleware for the grunt-contrib-connect plugin. It makes your test suite less brittle and has the potential to speed up test runs tremendously. This allows you to avoid the complexity of testing a fully integrated application. Instead of taking the time to setup mocking infrastructure on your front end you can simply record 3rd party calls your e2e testsuite makes and then mock them out during future test runs. Speed up client side end to end and integration tests Having a way to record & mock calls to the backend can eliminate a lot of troubleshooting cycles and complexity from your development of a modern front end Single Page Application. In extreme cases, you may not even host it locally or have access to change anything. The backend introduces a number of different variables to your development practices. Setting up a full stack for your web app can be costly and time consuming. ![]() Prism is most useful for mocking complex & high latency API calls during development. Why would I want to use it? Speed up development time The rest of this blog post will cite examples that are demonstrated in prism-sample-project. I've written a sample project that uses the grunt-connect-prism project. It's like an HTTP cache that persists cached responses to the disk and is only active when you explicitly turn it on. It allows you to work independently of the backend. After recording you can then replay the responses when requested and disconnect from the actual backend. The purpose of this plugin is to provide an easy way for you to record HTTP responses returned by your backend API (or some other remote web resource). If you're a RoR aficionado then you've probably heard of the project VCR, which is the inspiration for Prism. ![]() Grunt-connect-prism is a new grunt plugin I've written to help make developing a Single Page Application (SPA) easier. Gulp support is in experimental mode right now, but if there's anything else you would like to see then I encourage you to post an issue on my repo's issue tracker. connect/express example app.EDIT 26/6/14: I've had a lot of great feedback from everyone. Ignore gives you the possibility to ignore certain files or url's from being handled by connect-livereload. If you need liveReload on static html files, then place it before the static routes. In your connect or express application add this after the static and before the dynamic routes. grunt-contrib-connect or grunt-contrib-watch.Ĭonnect-livereload itself does not serve the livereload.js script. ![]() This middleware can be used with a LiveReload module e.g. Note: if you use this middleware, you should make sure to switch off the Browser LiveReload Extension if you have it installed. Install npm install connect-livereload -save-dev If you are happy with a browser plugin, then you don't need this middleware. Connect middleware for adding the livereload script to the response. ![]()
0 Comments
Leave a Reply. |