How to use the @ember/test-helpers.isSettled function in @ember/test-helpers

To help you get started, we’ve selected a few @ember/test-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember-test-helpers / tests / test-helper.js View on Github external
}

  // 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);
  }
});
github emberjs / ember-qunit / addon-test-support / ember-qunit / test-isolation-validation.js View on Github external
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`,
    });
  }
}
github DefinitelyTyped / DefinitelyTyped / types / ember__test-helpers / ember__test-helpers-tests.ts View on Github external
test('wait helpers', async (assert) =&gt; {
    await render(hbs`<div class="message">Hello</div>`);

    await waitFor('.message', { count: 1, timeout: 10, timeoutMessage: 'uh oh' });
    await waitUntil(() =&gt; 'hello', { timeout: 1000, timeoutMessage: 'boom' });

    await settled();
    assert.ok(isSettled());

    const {
        hasPendingRequests,
        hasPendingTimers,
        hasPendingWaiters,
        hasRunLoop,
        pendingRequestCount
    } = getSettledState();
});