// Type definitions for ember-qunit 5.0 // Project: https://github.com/emberjs/ember-qunit#readme // Definitions by: Dan Freeman // Chris Krycho // James C. Davis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 4.4 import EmberTestAdapter from '@ember/test/adapter'; import { Resolver } from '@ember/owner'; import { TestContext } from '@ember/test-helpers'; /** * Sets a Resolver globally which will be used to look up objects from each test's container. */ export function setResolver(resolver: Resolver): void; /** * Options for configuring the test runner. Normally, you will not need to * customize this. It is exported primarily so that end user app code can name * it when passing it back to the framework. */ export interface SetupTestOptions { /** * The resolver to use when instantiating container-managed entities in the test. */ resolver?: Resolver | undefined; } /** * Sets up acceptance tests. * * The `setupApplicationTest` function is used for all acceptance tests. It * is invoked in the callback scope of a QUnit module (aka "nested module"). * * Once invoked, all subsequent hooks.beforeEach and test invocations will * have access to the following: * * `this.owner` - the owner object that been set on the test context. * * `this.pauseTest` and `this.resumeTest` - allow easy pausing/resuming of tests. * * `this.element` which returns the DOM element representing the application's root element. */ export function setupApplicationTest( hooks: NestedHooks, options?: SetupTestOptions ): void; /** * Sets up tests that need to render snippets of templates. * * The setupRenderingTest method is used for tests that need to render * snippets of templates. It is also invoked in the callback scope of a * QUnit module (aka "nested module"). * * Once invoked, all subsequent hooks.beforeEach and test invocations will * have access to the following: * * All of the methods / properties listed for `setupTest` * * this.render(...) - Renders the provided template snippet returning a * promise that resolves once rendering has completed * * An importable render function that de-sugars into this.render will be * the default output of blueprints * * this.element - Returns the native DOM element representing the element * that was rendered via this.render * * this.$(...) - When jQuery is present, executes a jQuery selector with * the current this.element as its root */ export function setupRenderingTest( hooks: NestedHooks, options?: SetupTestOptions ): void; /** * Sets up tests that do not need to render snippets of templates. * * The `setupTest` method is used for all types of tests except for those * that need to render snippets of templates. It is invoked in the callback * scope of a QUnit module (aka "nested module"). * * Once invoked, all subsequent hooks.beforeEach and test invocations will * have access to the following: * * this.owner - This exposes the standard "owner API" for the test environment. * * this.set / this.setProperties - Allows setting values on the test context. * * this.get / this.getProperties - Retrieves values from the test context. */ export function setupTest(hooks: NestedHooks, options?: SetupTestOptions): void; export class QUnitAdapter extends EmberTestAdapter {} export { module, test, skip, only, todo } from 'qunit'; interface QUnitStartOptions { /** * If `false` tests will not be loaded automatically. */ loadTests?: boolean | undefined; /** * If `false` the test container will not be setup based on `devmode`, * `dockcontainer`, or `nocontainer` URL params. */ setupTestContainer?: boolean | undefined; /** * If `false` tests will not be automatically started (you must run * `QUnit.start()` to kick them off). */ startTests?: boolean | undefined; /** * If `false` the default Ember.Test adapter will not be updated. */ setupTestAdapter?: boolean | undefined; /** * `false` opts out of the default behavior of setting `Ember.testing` * to `true` before all tests and back to `false` after each test will. */ setupEmberTesting?: boolean | undefined; /** * If `false` validation of `Ember.onerror` will be disabled. */ setupEmberOnerrorValidation?: boolean | undefined; /** * If `false` test isolation validation will be disabled. */ setupTestIsolationValidation?: boolean | undefined; } export function start(options?: QUnitStartOptions): void; // SAFETY: all of the `TC extends TestContext` generics below are just wildly, // impossibly unsafe. QUnit cannot -- ever! -- guarantee that the test context // is properly set up in a type-safe way to match this. However, it is the only // way to handle setting state in a TS-visible way prior to Ember RFC 0785, // which is slooooowly rolling out across the ecosystem in conjunction with the // `