mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add this.currentTest to setup and teardown
This commit is contained in:
parent
5cdb98e158
commit
2402e987f0
19
mocha/index.d.ts
vendored
19
mocha/index.d.ts
vendored
@ -49,18 +49,18 @@ interface MochaDone {
|
||||
(error?: any): any;
|
||||
}
|
||||
|
||||
declare function setup(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function teardown(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function setup(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
|
||||
declare function teardown(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
|
||||
declare function suiteSetup(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function suiteTeardown(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function before(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function before(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function after(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function after(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function beforeEach(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function beforeEach(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function afterEach(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function afterEach(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
|
||||
declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
|
||||
declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
|
||||
declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
|
||||
declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
|
||||
|
||||
declare class Mocha {
|
||||
currentTest: Mocha.ITestDefinition;
|
||||
@ -120,6 +120,7 @@ declare namespace Mocha {
|
||||
timeout(ms: number): void;
|
||||
}
|
||||
|
||||
|
||||
interface ITestCallbackContext {
|
||||
skip(): void;
|
||||
timeout(ms: number): void;
|
||||
@ -148,10 +149,16 @@ declare namespace Mocha {
|
||||
interface ITest extends IRunnable {
|
||||
parent: ISuite;
|
||||
pending: boolean;
|
||||
state: 'failed'|'passed'|undefined;
|
||||
|
||||
fullTitle(): string;
|
||||
}
|
||||
|
||||
interface IBeforeAndAfterContext extends IHookCallbackContext {
|
||||
currentTest: ITest;
|
||||
}
|
||||
|
||||
|
||||
/** Partial interface for Mocha's `Runner` class. */
|
||||
interface IRunner { }
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
let boolean: boolean;
|
||||
let string: string;
|
||||
|
||||
function test_describe() {
|
||||
describe('something', () => { });
|
||||
@ -108,9 +110,26 @@ function test_before() {
|
||||
}
|
||||
|
||||
function test_setup() {
|
||||
setup(() => { });
|
||||
setup(function() {
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
setup((done) => { done(); });
|
||||
setup(function (done) {
|
||||
done();
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
}
|
||||
|
||||
function test_after() {
|
||||
@ -124,19 +143,70 @@ function test_after() {
|
||||
}
|
||||
|
||||
function test_teardown() {
|
||||
teardown(() => { });
|
||||
teardown(function() {
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
teardown((done) => { done(); });
|
||||
teardown(function(done) {
|
||||
done();
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
}
|
||||
|
||||
function test_beforeEach() {
|
||||
beforeEach(() => { });
|
||||
beforeEach(function () {
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
beforeEach((done) => { done(); });
|
||||
beforeEach(function (done) {
|
||||
done();
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
beforeEach("my description", () => { });
|
||||
beforeEach("my description", function() {
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
beforeEach("my description", done => { });
|
||||
beforeEach("my description", function(done) {
|
||||
done();
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
}
|
||||
|
||||
function test_suiteSetup() {
|
||||
@ -146,13 +216,48 @@ function test_suiteSetup() {
|
||||
}
|
||||
|
||||
function test_afterEach() {
|
||||
afterEach(() => { });
|
||||
afterEach(function () {
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
afterEach((done) => { done(); });
|
||||
afterEach(function (done) {
|
||||
done();
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
afterEach("my description", () => { });
|
||||
afterEach("my description", function() {
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
afterEach("my description", function(done) {
|
||||
done();
|
||||
boolean = this.currentTest.async;
|
||||
boolean = this.currentTest.pending;
|
||||
boolean = this.currentTest.sync;
|
||||
boolean = this.currentTest.timedOut;
|
||||
string = this.currentTest.title;
|
||||
string = this.currentTest.fullTitle();
|
||||
string = this.currentTest.state;
|
||||
});
|
||||
|
||||
afterEach("my description", done => { });
|
||||
}
|
||||
|
||||
function test_suiteTeardown() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user