Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// this is used to ensure that the testing container is always reset properly
let testElementContainer = document.getElementById('ember-testing-container');
let actual = testElementContainer.innerHTML;
let expected = `<div id="ember-testing"></div>`;
if (actual !== expected) {
let message = `Expected #ember-testing-container to be reset after ${module}: ${name}, but was \`${actual}\``;
cleanupFailures.push(message);
// eslint-disable-next-line
console.error(message);
testElementContainer.innerHTML = expected;
}
if (!isSettled()) {
let message = `Expected to be settled after ${module}: ${name}, but was \`${JSON.stringify(
getSettledState()
)}\``;
asyncLeakageFailures.push(message);
// eslint-disable-next-line
console.error(message);
}
});
export function detectIfTestNotIsolated(test, message = '') {
if (!isSettled()) {
let { debugInfo } = getSettledState();
console.group(`${test.module.name}: ${test.testName}`);
debugInfo.toConsole();
console.groupEnd();
test.expected++;
test.assert.pushResult({
result: false,
message: `${message} \nMore information has been printed to the console. Please use that information to help in debugging.\n\n`,
});
}
}
test('wait helpers', async (assert) => {
await render(hbs`<div class="message">Hello</div>`);
await waitFor('.message', { count: 1, timeout: 10, timeoutMessage: 'uh oh' });
await waitUntil(() => 'hello', { timeout: 1000, timeoutMessage: 'boom' });
await settled();
assert.ok(isSettled());
const {
hasPendingRequests,
hasPendingTimers,
hasPendingWaiters,
hasRunLoop,
pendingRequestCount
} = getSettledState();
});