Create a Spike to Gain Insight

The next logical step is the design of the getPrice function. This function should visit Yahoo Finance to get the stock data for a given ticker symbol, parse the data for price, and invoke printReport. It also should handle errors that may occur. There’s a lot going on and it sounds like it involves a few moving parts.

The function is complex enough that most of us can’t write it in one shot, let alone write the tests first. We need to change our approach. We’ll create a spike to gain much needed insights about this function.

Spike for getPrice

Let’s think through the tests for getPrice. It may feel like a struggle and that’s because it’s quite hard to envision the full implementation of getPrice. When ...

Get Test-Driving JavaScript Applications 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.