UNPKG

2.65 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/nodeunit`
3
4# Summary
5This package contains type definitions for nodeunit (https://github.com/caolan/nodeunit).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/nodeunit.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/nodeunit/index.d.ts)
10````ts
11// Imported from: https://github.com/soywiz/typescript-node-definitions/nodeunit.d.ts
12
13export interface ITestCase {
14 (testCase: { [property: string]: ITestBody | ITestGroup | void }): void;
15}
16export declare var testCase: ITestCase;
17
18export interface Test {
19 done: ICallbackFunction;
20 expect(num: number): void;
21
22 // assersions from node assert module
23 fail(actual: any, expected: any, message: string, operator: string): void;
24 assert(value: any, message: string): void;
25 ok(value: any, message?: string): void;
26 equal(actual: any, expected: any, message?: string): void;
27 notEqual(actual: any, expected: any, message?: string): void;
28 deepEqual(actual: any, expected: any, message?: string): void;
29 notDeepEqual(actual: any, expected: any, message?: string): void;
30 strictEqual(actual: any, expected: any, message?: string): void;
31 notStrictEqual(actual: any, expected: any, message?: string): void;
32 throws(block: any, error?: any, message?: string): void;
33 doesNotThrow(block: any, error?: any, message?: string): void;
34 ifError(value: any): void;
35
36 // assertion wrappers
37 equals(actual: any, expected: any, message?: string): void;
38 same(actual: any, expected: any, message?: string): void;
39}
40
41// Test Group Usage:
42// var testGroup: nodeunit.ITestGroup = {
43// setUp: (callback) => {
44// callback();
45// },
46// tearDown: (callback) => {
47// callback();
48// },
49// test1: (test: nodeunit.Test) => {
50// test.done();
51// }
52// }
53// exports.testgroup = testGroup;
54
55export interface ITestBody {
56 (callback: Test): void;
57}
58
59export interface ITestGroup {
60 /** The setUp function is run before each test */
61 setUp?: ((callback: ICallbackFunction) => void) | undefined;
62 /** The tearDown function is run after each test calls test.done() */
63 tearDown?: ((callback: ICallbackFunction) => void) | undefined;
64 [property: string]: ITestGroup | ITestBody | ((callback: ICallbackFunction) => void) | undefined;
65}
66
67export interface ICallbackFunction {
68 (err?: any): void;
69}
70
71````
72
73### Additional Details
74 * Last updated: Mon, 29 Jul 2024 19:36:25 GMT
75 * Dependencies: none
76
77# Credits
78These definitions were written by .
79
\No newline at end of file