Prasanna Natarajan

Understanding Turbolinks by Reading Tests

The Turbolinks Readme documents the library’s workings in great details. To fully get it, we might build a rails 5 app and try it out. But there’s a faster way to get to know the library and its working - by reading the test cases in the source.

This section explains how we can first run the whole test suite after cloning the repo locally.

Once cloned and setup, the bin/blade runner command runs all test cases (the QUnit library is used as the test library).

The test cases are grouped into 3 modules - navigation_tests.coffee, rendering_tests.coffee, visits_tests.coffee.

The automated tests are hard to make sense of without trying them manually. For example, this testcase - “following a same-origin unannotated link” asserts that clicking a TL enabled link,

Wouldn’t it be nice to see it ourselves?

All you have to do is 2 things:

And then, followup with the coffee testcases and visit the corresponding files in the fixtures folder.

That’s it.

Things I learnt from going through the test cases: