- Create test dir in the root of the project.
- Put
tsconfig.json
into test folder. - Put
testup.d.ts
into test folder. - Create test scenario like in
index.spec.ts
.
Created
October 20, 2021 02:20
-
-
Save rumkin/2635982309381121d1ba8f606c776cb9 to your computer and use it in GitHub Desktop.
Testup typescript setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ({define, it}: Testup.ScriptScope) => { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface DescribeFn { | |
(label: string, handler: ScriptFn): void | |
} | |
export interface ItFn { | |
(label: string, ...spec: [...ModifierFn[], TestCaseFn]): void | |
} | |
export interface UseFn { | |
(modifier: ModifierFn): void | |
} | |
export interface EachFn { | |
(modifiers: ModifierFn): void | |
} | |
export interface Test { | |
delay(timeout: number): Promise<void> | |
end():void | |
} | |
export type TestCtx = Record<string|symbol, any> | |
export interface TestCaseFn { | |
(context: TestCtx, test: Test): void | |
} | |
export interface ModifierFn { | |
(context: TestCtx, next: () => Promise<void>): void|Promise<void> | |
} | |
export interface ScriptFn { | |
(scope: ScriptScope): void | |
} | |
export interface ScriptScope { | |
define: DescribeFn; | |
use: UseFn; | |
each: EachFn; | |
it: ItFn; | |
} | |
// Reexport ScriptScope | |
type _ScriptScope = ScriptScope | |
declare namespace Testup { | |
export interface ScriptScope extends _ScriptScope {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"files": [ | |
"./testup.d.ts", | |
], | |
"include": ["**/*.spec.ts"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment