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.

👋 Hey there, Ember dev!

We hope you enjoyed this free video 🙂

If you like it and want to keep learning with us, we've written a free 6-lesson email course about the fundamental patterns of modern component design in Ember.

To get the first lesson now, enter your best email address below:

You can also check out more details about the course by clicking here.

Questions?

Send us a tweet:

Or ask us in Inside EmberMap, our private Slack workspace for subscribers.