Common utilities for every app to help making testing easier.
A typed way to get a service.
import{getService}from'@universal-ember/test-support';test('can get a service',asyncfunction(assert){letrouter=getService('router');// ^ RouterService});a no-op function. literally does nothing.
import { noop } from'@universal-ember/test-support';
<template>
{{(noop)}}
</template>Simulates refreshing the page without reloading the test window
import{module,test}from'qunit';import{setupApplicationTest}from'ember-qunit';import{currentURL,visit}from'@ember/test-helpers';import{refresh}from'@universal-ember/test-support';module('refresh',function(hooks){setupApplicationTest(hooks);test('are visitable without error',asyncfunction(assert){awaitvisit('/foo');awaitrefresh(this);assert.strictEqual(currentURL(),'/foo');});});Will visit all links, recursively, exhausting every link in your app (excluding external links).
This is helpful for making sure that no un-tested pages have errors.
import{module,test}from'qunit';import{setupApplicationTest}from'ember-qunit';import{visitAllLinks}from'@universal-ember/test-support';module('All Links',function(hooks){setupApplicationTest(hooks);test('are visitable without error',asyncfunction(assert){constsize1=awaitvisitAllLinks();constsize2=awaitvisitAllLinks((url)=>{assert.ok(url);});assert.ok(size1>0,'The test app has links');assert.ok(size2>0,'The test app has links');});});