Search⌘ K
AI Features

Unit Test a Function

Explore writing effective unit tests for JavaScript functions using Jasmine. Understand how to create spec files, test array flatMap behavior with multiple cases, and improve test clarity with descriptive names.

flat-Map tests

Let’s try and write the function and tests from the previous lesson using Jasmine.

We want to have the spec file right next to the source file. That way, the spec is separate from the production code but still close at hand.

To ...