europa-test
Version:
Test framework for Europa Core implementations
46 lines (45 loc) • 2.16 kB
TypeScript
import { EuropaCore, EuropaOptions } from 'europa-core';
import { TestFixture } from "./TestFixture";
/**
* Creates a full test suite for a `europa-core` implementation package using the `options` provided.
*
* @param options - The options to be used.
*/
export declare function test<T extends EuropaCore<N, E>, N, E extends N>(options: TestOptions<T, N, E>): void;
/**
* The options used by `europa-test`.
*/
export declare type TestOptions<T extends EuropaCore<N, E>, N, E extends N> = {
/**
* The function to be used to create an instance of the {@link EuropaCore} implementation to be tested using the
* `options` provided.
*
* @param [options] - The options to be used.
* @return An instance of the {@link EuropaCore} implementation.
*/
readonly createEuropa: (options?: EuropaOptions) => T;
/**
* Any additional test fixtures that are only of interest to a specific implementation of {@link EuropaCore}.
*
* Typically, it is recommended that test fixtures are implementation agnostic, and it's preferred to contribute to
* the bundled test fixtures over building an implementation-specific test suite.
*/
readonly extraFixtures?: TestFixture<N>[];
/**
* The function to be used to load the contents of a test fixture file.
*
* If `bundled` is `true`; `path` will target a file bundled within `europa-test` itself and should be conform to the
* pattern: `node_modules/europa-test/fixtures/*.(html|md)`. Otherwise, `path` will be whatever was provided as the
* fixtures `baseFilePath` with either `.html` or `.md` appended to it.
*
* @param path - The path of the fixture file whose contents are to be loaded.
* @param bundled - `true` if the fixture file is bundled within `europa-test`; otherwise `false`.
* @return The contents of the test fixture file.
* @throws If unable to read the test fixture file.
*/
readonly loadFixtureFile: (path: string, bundled: boolean) => Promise<string>;
/**
* The name of the `europa-core` implementation package being tested.
*/
readonly packageName: string;
};