Create definitions for gulp-jasmine@2.4 (#21431)

* Create definitions for gulp-jasmine@2.4

* Fix the 'reporter' property

Functionality:
 - Make the secondary type of the 'reporter' property in JasmineOptions ReadonlyArray<jasmine.CustomReporter> instead of jasmine.CustomReporter[].

Tests:
 - Add some more tests

Testing done: npm run lint gulp-jasmine (with and without the change to verify the tests fail properly)

* Remove unnecessary empty namespace.
This commit is contained in:
Confidential
2017-11-13 16:55:30 +02:00
committed by Andy
parent bf47dab3b5
commit 112cd72e92
4 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import gulpJasmine = require("gulp-jasmine");
import jasmine = require("jasmine");
const dummyReporter: jasmine.CustomReporter = {};
gulpJasmine(); // $ExpectType ReadWriteStream
gulpJasmine({});
gulpJasmine({
verbose: true,
includeStackTrace: true,
reporter: dummyReporter,
timeout: 1000,
errorOnFail: false,
config: {}
});
gulpJasmine({ reporter: [dummyReporter, dummyReporter] });
const readonlyDummyReporters: ReadonlyArray<jasmine.CustomReporter> = [
dummyReporter, dummyReporter
];
gulpJasmine({ reporter: readonlyDummyReporters });

50
types/gulp-jasmine/index.d.ts vendored Normal file
View File

@@ -0,0 +1,50 @@
// Type definitions for gulp-jasmine 2.4
// Project: https://github.com/sindresorhus/gulp-jasmine#readme
// Definitions by: Andrey Lalev <https://github.com/andypyrope>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
/// <reference types="jasmine" />
interface JasmineOptions {
/**
* Display spec names in default reporter.
*/
verbose?: boolean;
/**
* Include stack traces in failures in default reporter.
* @default false
*/
includeStackTrace?: boolean;
/**
* Reporter(s) to use.
*/
reporter?: jasmine.CustomReporter | ReadonlyArray<jasmine.CustomReporter>;
/**
* Time to wait in milliseconds before a test automatically fails.
* @default 5000
*/
timeout?: number;
/**
* Stops the stream on failed tests.
* @default true
*/
errorOnFail?: boolean;
/**
* Passes the config to Jasmine's loadConfig method.
*/
config?: object;
}
/**
* Executes Jasmine tests. Emits a 'jasmineDone' event on success.
* @param options Optional options for the execution of the Jasmine test
*/
declare function gulpJasmine(options?: JasmineOptions): NodeJS.ReadWriteStream;
export = gulpJasmine;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gulp-jasmine-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }