Chapter 13. Testing server-side rendering

 

This chapter covers

  • Understanding server-side rendering
  • Unit testing server-side rendered Vue components
  • Testing HTTP response codes from a server

Server-side rendering (SSR) is when you render the HTML code of an application on the server before returning it to the client. It’s common to use Vue for SSR, so to be a versatile Vue tester you should learn the techniques to test server-side rendered apps.

SSR is a big topic—too big to go over in a book on testing—so this chapter won’t teach you the specifics of how to add SSR to an app. Instead, I’ve converted the Hacker News app into an SSR app by following the official guide (https://vuejs.org/v2/guide/ssr.html). That way, you can focus on testing, rather than adding boilerplate.

Note

To follow along with this chapter, you need to switch to the chapter-13 branch of the Git project. If you’ve forgotten how to do that, you can go to appendix A for instructions. You’re going to use Node in this chapter to serve the application, so you’ll need an understanding of serving applications with Node.

Although I’m not going to teach the technical details involved in setting up a SSR app, I’ll give you a high-level overview of SSR. You don’t need to be familiar with SSR to follow along with this chapter and learn some useful skills.

13.1. Understanding server-side rendering

13.2. Testing server-side rendered components

13.3. Testing status codes with SuperTest

13.4. Testing SSR implicitly

Summary

Exercises

sitemap