Implementation:DevExpress Testcafe Structure TypeDefs
| Knowledge Sources | |
|---|---|
| Domains | Type_Definitions, Testing |
| Last Updated | 2026-02-12 12:00 GMT |
Overview
Concrete TypeScript type declarations for TestCafe's test structure APIs -- the fixture and test functions that form the organizational building blocks of every test file.
Description
This file declares the FixtureCtx and TestCtx context types, the FixtureFn interface (with page, meta, beforeEach, afterEach, before, after, httpAuth, requestHooks, skipJsErrors, clientScripts, disablePageReloads, disablePageCaching, only, skip), the TestFn interface (with page, meta, before, after, httpAuth, requestHooks, skipJsErrors, clientScripts, only, skip, timeouts), and the global function signatures for fixture() and test().
Usage
These types are globally available in TypeScript test files and enable IntelliSense for the fixture() and test() functions that define test structure.
Code Reference
Source Location
- Repository: DevExpress_Testcafe
- File: ts-defs-src/test-api/structure.d.ts
- Lines: 1-242
Signature
interface FixtureFn {
(name: string | TemplateStringsArray, ...args: any[]): this;
page(url: string | TemplateStringsArray, ...args: any[]): this;
meta(name: string, value: string): this;
meta(meta: Record<string, string>): this;
beforeEach(fn: (t: TestController) => Promise<any>): this;
afterEach(fn: (t: TestController) => Promise<any>): this;
before(fn: (ctx: object) => Promise<any>): this;
after(fn: (ctx: object) => Promise<any>): this;
httpAuth(credentials: HTTPAuthCredentials): this;
requestHooks(...hooks: object[]): this;
clientScripts(scripts: ClientScript | ClientScript[]): this;
skipJsErrors(opts?: boolean | SkipJsErrorsCallbackOptions | SkipJsErrorsOptionsObject): this;
disablePageReloads: this;
disablePageCaching: this;
only: this;
skip: this;
}
interface TestFn {
(name: string | TemplateStringsArray, fn: (t: TestController) => Promise<any>, ...args: any[]): this;
page(url: string | TemplateStringsArray, ...args: any[]): this;
meta(name: string, value: string): this;
meta(meta: Record<string, string>): this;
before(fn: (t: TestController) => Promise<any>): this;
after(fn: (t: TestController) => Promise<any>): this;
httpAuth(credentials: HTTPAuthCredentials): this;
requestHooks(...hooks: object[]): this;
clientScripts(scripts: ClientScript | ClientScript[]): this;
timeouts(timeouts: TestTimeouts): this;
only: this;
skip: this;
}
declare const fixture: FixtureFn;
declare const test: TestFn;
Import
// Globally available — no import needed in TestCafe test files
// Or use named import:
import { fixture, test } from 'testcafe';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Fixture or test name |
| fn | (t: TestController) => Promise | Yes (test) | Test body function receiving test controller |
| url | string | No | Page URL to navigate to before running |
Outputs
| Name | Type | Description |
|---|---|---|
| FixtureFn | FixtureFn | Chainable fixture configuration object |
| TestFn | TestFn | Chainable test configuration object |
Usage Examples
import { Selector } from 'testcafe';
fixture('User Authentication')
.page('https://example.com/login')
.meta({ priority: 'high', team: 'auth' })
.beforeEach(async (t: TestController) => {
await t.maximizeWindow();
})
.afterEach(async (t: TestController) => {
await t.takeScreenshot();
});
test('Login with valid credentials', async (t: TestController) => {
await t
.typeText('#email', 'user@example.com')
.typeText('#password', 'password123')
.click('#submit');
await t.expect(Selector('.dashboard').exists).ok();
});
test.skip('Login with SSO', async (t: TestController) => {
// Skipped test
});
test
.meta({ severity: 'critical' })
.before(async (t: TestController) => {
// Per-test setup
})
('Another test', async (t: TestController) => {
// test body
});