Company
Date Published
Author
Rob Sutter
Word count
1761
Language
English
Hacker News points
1

Summary

This post explains how to apply Test-Driven Development (TDD) to write and test queries with the Fauna Query Language (FQL). The author provides a general pattern for TDD with FQL, which involves writing a single failing test, implementing the functionality of a single "unit" of code, running tests as you make changes, and adding more tests or refactoring existing code once the initial implementation is complete. The post assumes users have access to a Fauna account, Node.js v12 or later, Jest, and JavaScript. It guides readers through setting up their environment, testing partial FQL expressions, creating a test harness, writing a single failing test for a "Split" function that accepts string and delimiter parameters, implementing the Split function while running unit tests in watch mode, reviewing and next steps, and additional resources.