# Unit Testing Your Application

In the previous lessons, we learned how to use [Resources & Resource Controller](/quick-start/my-first-application/resources-and-resource-controllers.md) to simplify the controllers implementation. Now, we need to test our implementation so we can ensure it is handling requests correctly.

Blueprint uses [mocha](https://mochajs.org/) and [`superagent`](https://www.npmjs.com/package/superagent) to facilitate unit testing. The benefit to Blueprint approach is it allows you to run unit tests without needing a front-end, such as Postman, to exercise the Blueprint application. You can also use [`chai`](https://www.chaijs.com/) to implement the test oracle for each unit test.

Using our current example, here is a simple unit test to check the `GET /api/rentals`.

```javascript
// tests/unit-tests/app/routers/rental.js

const { request } = require ('@onehilltech/blueprint-testing');
const { expect } = require ('chai');

describe ('app | routers | rental', function () {
  context ('GET', function () {
    it ('should get all the rentals', async function () {
      // Send a mock request to the api, and wait for the response.
      const res = await request ()
        .post ('/api/rentals')
        .expect (200);
        
      // res.body has the text from the response. 
      // From here you can use chai to implement test oracle via assertions.
    });
  });
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blueprint.onehilltech.com/quick-start/my-first-application/unit-testing-your-application.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
