FastBoot testing
Learn how to write acceptance tests against FastBoot-generated HTML.
Summary
Ember CLI FastBoot Testing is a new addon to help you write acceptance-like tests against your FastBooted Ember application.
We're going to be using it to add a FastBoot test against the /about
page of EmberMap.
ember install ember-cli-fastboot-testing
We can use a generator to generate our first test:
ember g fastboot-test about-page
Here's what we end up with:
import { module, test } from 'qunit';
import { setup, visit } from 'ember-cli-fastboot-testing/test-support';
module('FastBoot | about-page test', function(hooks) {
setup(hooks);
test('it renders the about page', async function(assert) {
await visit('/about');
assert.dom('h2').hasText('We love Ember');
});
test('it renders the right title', async function(assert) {
let { htmlDocument } = await visit('/about');
assert.dom('title', htmlDocument).hasText('About EmberMap');
});
test('it responses with success', async function(assert) {
let { statusCode } = await visit('/about');
assert.equal(statusCode, 200);
})
});
FastBoot tests are focused on verifying the initial render from your FastBoot-generated HTML. User behavior like following links and filling in forms should be covered by your normal Ember acceptance tests.