@@ -7,32 +7,23 @@ import test from 'tape';
77// @if mocha
88import { expect } from 'chai';
99// @endif
10- import Aurelia, { CustomElement } from 'aurelia';
10+ import { TestContext, TestConfiguration } from '@aurelia/testing';
11+ import Aurelia/* @if shadow-dom */, { CustomElement }/* @endif */ from 'aurelia';
1112import { MyApp } from '../src/my-app';
1213
13- // @if babel
14- function createAu(template, ...deps) {
15- // @endif
16- // @if typescript
17- function createAu(template: string, ...deps: readonly unknown[]) {
18- // @endif
19- const wrapper = CustomElement.define({name: 'wrapper', template});
20- document.body.appendChild(document.createElement('wrapper'));
21- return Aurelia.register(deps).app(wrapper);
22- }
23-
24- function cleanup() {
25- const wrapper = document.querySelector('wrapper');
26- if (wrapper) {
27- wrapper.remove();
28- }
29- }
30-
3114// @if ava || tape
3215test('my-app: should render message', async t => {
33- const au = createAu('<my-app></my-app>', MyApp);
16+ const ctx = TestContext.createHTMLTestContext();
17+ const { container } = ctx;
18+ const node = ctx.createElement('my-app');
19+
20+ const au = new Aurelia(container)
21+ .register(TestConfiguration)
22+ .app({ host: node, component: MyApp });
23+
24+ // const component = au.root.controller.bindingContext;
3425 await au.start().wait();
35- const node = document.querySelector('my-app');
26+
3627 // @if shadow-dom
3728 // In Shadow DOM open mode, shadowRoot is also accessible through DOM API
3829 // node.shadowRoot
@@ -55,22 +46,25 @@ test('my-app: should render message', async t => {
5546 t.equal(text.trim(), 'Hello World!');
5647 // @endif
5748 await au.stop().wait();
58- cleanup();
5949 // @if tape
6050 t.end();
6151 // @endif
6252});
6353// @endif
6454// @if jasmine || jest || mocha
6555describe('my-app', () => {
66- afterEach(() => {
67- cleanup();
68- });
69-
7056 it('should render message', async () => {
71- const au = createAu('<my-app></my-app>', MyApp);
57+ const ctx = TestContext.createHTMLTestContext();
58+ const { container } = ctx;
59+ const node = ctx.createElement('my-app');
60+
61+ const au = new Aurelia(container)
62+ .register(TestConfiguration)
63+ .app({ host: node, component: MyApp });
64+
65+ // const component = au.root.controller.bindingContext;
7266 await au.start().wait();
73- const node = document.querySelector('my-app');
67+
7468 // @if shadow-dom
7569 // In Shadow DOM open mode, shadowRoot is also accessible through DOM API
7670 // node.shadowRoot
@@ -93,7 +87,6 @@ describe('my-app', () => {
9387 expect(text.trim()).to.equal('Hello World!');
9488 // @endif
9589 await au.stop().wait();
96- cleanup();
9790 });
9891});
9992// @endif
0 commit comments