<commit_before>---
title: Acceptance
---

# Acceptance Testing

Denali comes with some testing helpers out of the box to make acceptance
testing simpler. Here's a quick sample of what an acceptance test might look
like:

```js
import test from 'ava';
import { appAcceptanceTest } from 'denali';

appAcceptanceTest(test);

test('GET /posts/:id returns the requested post', async (t) => {
  let app = t.context.app;
  let db = app.lookup('service:db');
  await db.create('post', { title: 'Hello World' }).save();

  let { status, body } = await app.get('/posts/1');

  t.is(body.title, 'Hello World');
});
```

## `appAcceptanceTest(test)`

This is the starting point of the Denali test helpers. When defining an
acceptance test suite, just add `appAcceptanceTest()` to the top of the test file:

```js
import test from 'ava';
import { appAcceptanceTest } from 'denali';

appAcceptanceTest(test);

test('GET /posts/:id returns the requested post', async (t) => {
  // ...
```

`appAcceptanceTest()` will automatically handle the setup, initialization, and teardown
of an instance of your Application. It also adds the `t.context.app` property to the
test suite, and if your ORM adapters support test transactions, will automatically
start and rollback a transaction around your test.
<commit_msg>docs(guides): appAcceptanceTest usage (#422)<commit_after>---
title: Acceptance
---

# Acceptance Testing

Denali comes with some testing helpers out of the box to make acceptance
testing simpler. Here's a quick sample of what an acceptance test might look
like:

```js
import { appAcceptanceTest } from 'denali';

const test = appAcceptanceTest();

test('GET /posts/:id returns the requested post', async (t) => {
  let app = t.context.app;
  let db = app.lookup('service:db');
  await db.create('post', { title: 'Hello World' }).save();

  let { status, body } = await app.get('/posts/1');

  t.is(body.title, 'Hello World');
});
```

## `appAcceptanceTest()`

This is the starting point of the Denali test helpers. When defining an
acceptance test suite, just add `const test = appAcceptanceTest()` to the top of the test file
to set up your test suite:

```js
import { appAcceptanceTest } from 'denali';

const test = appAcceptanceTest();

test('GET /posts/:id returns the requested post', async (t) => {
  // ...
```

`appAcceptanceTest()` will automatically handle the setup, initialization, and teardown
of an instance of your Application. It also adds the `t.context.app` property to the
test suite, and if your ORM adapters support test transactions, will automatically
start and rollback a transaction around your test.

{'fraction_non_alphanumeric': 0.11852134146341463, 'fraction_numerical': 0.0019054878048780487, 'mean_word_length': 4.434782608695652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2733795', 'n_tokens_mistral': 778, 'n_tokens_neox': 756, 'n_words': 323}