The Router Function

Now that we’ve got a failing test, we can write the router function. To get our router test to pass, we have to add three things. We need to create a view container in the markup to give the router a place to add the views. We need to create the showView function and have it create a minimal version of the problem view. Lastly, we need to create a namespace where our router function—and the rest of our application—can live. Once those things are complete, we’ll have the first version of our router in place. All it will be able to do is switch from one view to another, but that’s a good start.

Since our test is complaining about not being able to find the learnjs namespace, we’re going to start with that.

Creating a Namespace ...

Get Serverless Single Page Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.