...

/

Writing Our First Test in Deno

Writing Our First Test in Deno

Learn to write tests in a Deno application.

We'll cover the following...

Before we start writing our test, it’s important to remember a few things. The most important of them is, why are we testing?

There might be multiple answers to this question, but most of them will gesture toward guaranteeing that the code is working. We might also say that utilizing them provides flexibility when it comes to refactoring or that valuing short feedback cycles during implementation is highly beneficial—we can agree with both of these perspectives. Since we didn’t write a test before implementing these features, the latter doesn’t apply too much to us.

We’ll keep these objectives in mind throughout this chapter. In this lesson, we’ll write our first test. We’ll use the application we wrote in the previous chapters and add tests to it. We’ll write two types of tests: integration and unit tests.

Integration tests will test how different components of the application interact. Unit tests test layers in isolation. If we think of it as a spectrum, unit tests are closer to the code, while integration tests are closer to the user. On the very end of the user side, there are also end-to-end tests. Those are the tests that test the application by emulating the user behavior, which we won’t cover in this chapter.

Parts ...