test('run once per test run', async function(assert) { let initializerCallCount = 0; isolatedApp.initializer({ name: 'foo', initialize() { initializerCallCount += 1; }, }); await teardownContext(await setupContext({})); assert.equal(initializerCallCount, 1); await teardownContext(await setupContext({})); assert.equal(initializerCallCount, 1); });
hooks.afterEach(async function() { if (context.owner) { await teardownContext(context); } document.getElementById('ember-testing').innerHTML = ''; });
hooks.afterEach(async function() { if (context) { await teardownContext(context); context = undefined; } setApplication(application); setResolver(resolver); });
hooks.afterEach(async function() { if (elementWithFocus) { elementWithFocus.parentNode.removeChild(elementWithFocus); } // only teardown if setupContext was called if (context.owner) { await teardownContext(context); } document.getElementById('ember-testing').innerHTML = ''; });
hooks.afterEach(async function() { if (element.parentNode) { element.parentNode.removeChild(element); } if (context.owner) { await teardownContext(context); } document.getElementById('ember-testing').innerHTML = ''; });
hooks.afterEach(async function() { element.setAttribute('data-skip-steps', true); if (element) { element.parentNode.removeChild(element); } if (context.owner) { await teardownContext(context); } document.getElementById('ember-testing').innerHTML = ''; });
test('changes to the DOM persist across multiple setupContext() calls', async function(assert) { function rootEl() { return document.querySelector(isolatedApp.rootElement); } isolatedApp.initializer({ name: 'foo', initialize() { let initializerDiv = document.createElement('div'); initializerDiv.id = 'initializer'; rootEl().appendChild(initializerDiv); }, }); try { let context = await setupContext({}); try { assert.ok(rootEl().lastChild); assert.equal(rootEl().lastChild.id, 'initializer'); } finally { await teardownContext(context); } context = await setupContext({}); try { assert.ok(rootEl().lastChild); assert.equal(rootEl().lastChild.id, 'initializer'); } finally { await teardownContext(context); } } finally { // Don't leave #ember-testing polluted for other tests if (rootEl().lastChild) { rootEl().lastChild.remove(); } } });
hooks.afterEach(async function() { await teardownApplicationContext(this); await teardownContext(this); });