https://github.com/universal-ember/test-support
A general purpose collection of utilities to make testing easier
https://github.com/universal-ember/test-support
Last synced: 11 months ago
JSON representation
A general purpose collection of utilities to make testing easier
- Host: GitHub
- URL: https://github.com/universal-ember/test-support
- Owner: universal-ember
- License: mit
- Created: 2024-03-04T04:01:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-13T21:31:37.000Z (11 months ago)
- Last Synced: 2025-07-13T23:32:17.417Z (11 months ago)
- Language: JavaScript
- Size: 802 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-ember - @universal-ember/test-support - Collection of additional, community maintained, test-utilities (Testing / Utilities)
README
# test-support
Common utilities for every app to help making testing easier.
## `getService`
A typed way to get a service.
```js
import { getService } from '@universal-ember/test-support';
test('can get a service', async function (assert) {
let router = getService('router');
// ^ RouterService
});
```
## `noop`
a no-op function. literally does nothing.
```gjs
import { noop } from '@universal-ember/test-support';
{{ ( noop ) }}
```
## `refresh`
Simulates refreshing the page without reloading the test window
```js
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', async function (assert) {
await visit('/foo');
await refresh(this);
assert.strictEqual(currentURL(), '/foo');
});
});
```
## `visitAllLinks`
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.
```js
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', async function (assert) {
const size1 = await visitAllLinks();
const size2 = await visitAllLinks((url) => {
assert.ok(url);
});
assert.ok(size1 > 0, 'The test app has links');
assert.ok(size2 > 0, 'The test app has links');
});
});
```