Unit Test a Function

Learn how to test a function using different inputs and outputs and how to name the tests.

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 that end, we have src/flat-map.js as the implementation and src/flat-map.spec.js as the spec.

Run

Run the code playground below.

Get hands-on with 1400+ tech skills courses.