mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
More robust Mocha definitions
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
setResolver, setupAcceptanceTest, setupComponentTest,
|
||||
setupModelTest, setupTest
|
||||
} from 'ember-mocha';
|
||||
import { context, describe, it, beforeEach, afterEach, before, after } from 'mocha';
|
||||
import { describe, it, beforeEach, afterEach, before, after } from 'mocha';
|
||||
import chai = require('chai');
|
||||
import Ember from "ember";
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
Vendored
+1
-2
@@ -60,6 +60,5 @@ declare module 'ember-mocha' {
|
||||
|
||||
declare module 'mocha' {
|
||||
// augment test callback context
|
||||
interface ITestCallbackContext extends TestContext {}
|
||||
interface IHookCallbackContext extends TestContext {}
|
||||
interface Context extends TestContext {}
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
mocha-node.d.ts
|
||||
mocha-node-tests.ts
|
||||
Vendored
+2750
-416
File diff suppressed because it is too large
Load Diff
+109
@@ -0,0 +1,109 @@
|
||||
import Mocha = require("../../");
|
||||
|
||||
export = common;
|
||||
|
||||
declare function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions;
|
||||
|
||||
declare namespace common {
|
||||
interface CommonFunctions {
|
||||
/**
|
||||
* This is only present if flag --delay is passed into Mocha. It triggers
|
||||
* root suite execution.
|
||||
*/
|
||||
runWithSuite(suite: Mocha.Suite): () => void;
|
||||
|
||||
/**
|
||||
* Execute before running tests.
|
||||
*/
|
||||
before(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute before running tests.
|
||||
*/
|
||||
before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after running tests.
|
||||
*/
|
||||
after(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after running tests.
|
||||
*/
|
||||
after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute before each test case.
|
||||
*/
|
||||
beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute before each test case.
|
||||
*/
|
||||
beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after each test case.
|
||||
*/
|
||||
afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
/**
|
||||
* Execute after each test case.
|
||||
*/
|
||||
afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
||||
|
||||
suite: SuiteFunctions;
|
||||
test: TestFunctions;
|
||||
}
|
||||
|
||||
interface CreateOptions {
|
||||
/** Title of suite */
|
||||
title: string;
|
||||
|
||||
/** Suite function */
|
||||
fn?: (this: Mocha.Suite) => void;
|
||||
|
||||
/** Is suite pending? */
|
||||
pending?: boolean;
|
||||
|
||||
/** Filepath where this Suite resides */
|
||||
file?: string;
|
||||
|
||||
/** Is suite exclusive? */
|
||||
isOnly?: boolean;
|
||||
}
|
||||
|
||||
interface SuiteFunctions {
|
||||
/**
|
||||
* Create an exclusive Suite; convenience function
|
||||
*/
|
||||
only(opts: CreateOptions): Mocha.Suite;
|
||||
|
||||
/**
|
||||
* Create a Suite, but skip it; convenience function
|
||||
*/
|
||||
skip(opts: CreateOptions): Mocha.Suite;
|
||||
|
||||
/**
|
||||
* Creates a suite.
|
||||
*/
|
||||
create(opts: CreateOptions): Mocha.Suite;
|
||||
}
|
||||
|
||||
interface TestFunctions {
|
||||
/**
|
||||
* Exclusive test-case.
|
||||
*/
|
||||
only(mocha: Mocha, test: Mocha.Test): Mocha.Test;
|
||||
|
||||
/**
|
||||
* Pending test case.
|
||||
*/
|
||||
skip(title: string): void;
|
||||
|
||||
/**
|
||||
* Number of retry attempts
|
||||
*/
|
||||
retries(n: number): void;
|
||||
}
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
export = milliseconds;
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html}
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html#~parse}
|
||||
*/
|
||||
declare function milliseconds(val: string): number;
|
||||
|
||||
/**
|
||||
* Format for `ms`.
|
||||
*
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html}
|
||||
* @see {@link https://mochajs.org/api/module-milliseconds.html#~format}
|
||||
*/
|
||||
declare function milliseconds(val: number): string;
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
|
||||
import MochaDef = require('mocha');
|
||||
|
||||
class CustomSpecReporter extends MochaDef.reporters.Spec {
|
||||
constructor(runner: Mocha.IRunner) {
|
||||
super(runner);
|
||||
|
||||
runner.on('test', (test: Mocha.ITest) => {
|
||||
console.log(test.parent.title + '/' + test.title);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class MyReporter extends MochaDef.reporters.Base {
|
||||
passes: number = 0;
|
||||
failures: number = 0;
|
||||
|
||||
constructor(runner: Mocha.IRunner) {
|
||||
super(runner);
|
||||
|
||||
runner.on('pass', (test: Mocha.ITest) => {
|
||||
this.passes++;
|
||||
console.log('pass: %s', test.fullTitle());
|
||||
});
|
||||
|
||||
runner.on('fail', (test: Mocha.ITest, err: Error) => {
|
||||
this.failures++;
|
||||
console.log('fail: %s -- error: %s', test.fullTitle(), err.message);
|
||||
});
|
||||
|
||||
runner.on('end', () => {
|
||||
console.log('end: %d/%d', this.passes, this.passes + this.failures);
|
||||
process.exit(this.failures);
|
||||
});
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
// Type definitions for mocha 2.2.5
|
||||
// Project: http://mochajs.org/
|
||||
// Definitions by: Vadim Macagon <https://github.com/enlight>, vvakame <https://github.com/vvakame>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare namespace Mocha {
|
||||
interface IRunnable extends NodeJS.EventEmitter {
|
||||
}
|
||||
interface ISuite extends NodeJS.EventEmitter {
|
||||
}
|
||||
interface IRunner extends NodeJS.EventEmitter {
|
||||
}
|
||||
}
|
||||
+1035
-405
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,8 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lib/ms.d.ts",
|
||||
"lib/interfaces/common.d.ts",
|
||||
"mocha-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user