The existing answer from @Tyler Becks is good for legacy ember-qunit, but with native qunit (since: 2017: https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md), you'd want something like this (known to work with at least Ember Octane (3.16+)):
import { test, module } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { hbs } from 'ember-cli-htmlbars';
import { render } from '@ember/test-helpers';
import { setComponentTemplate } from '@ember/component';
import templateOnly from '@ember/component/template-only';
import Component from '@glimmer/component';
module('name of test suite', function(hooks) {
setupRenderingTest(hooks);
test('name of test', async function(assert) {
class MyComponent extends Component {}
setComponetTemplate(hbs`your template here`, MyComponent);
this.owner.register('component:component-name', MyComponent);
await render(hbs`<ComponentName />`);
});
// alternatively, things get a bit simpler if you're using
// ember-source 3.25+
test('name of test 2', async function(assert) {
class MyComponent extends Component {}
setComponetTemplate(hbs`your template here`, MyComponent);
this.setProperties({ MyComponent });
await render(hbs`<this.MyComponent />`);
});
// template-only components are even simpler still
test('name of test 3', async function(assert) {
this.setProperties({
MyComponent: setComponetTemplate(
hbs`your template here`,
templateOnly()
);
});
await render(hbs`<this.MyComponent />`);
});
});