Add defenition for allure-js-commons

This commit is contained in:
Denis Artyuhovich
2018-05-22 18:17:21 +03:00
parent 88fc0023e6
commit 66150a31df
4 changed files with 157 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import * as Allure from "allure-js-commons";
const shouldMakeError = new Allure("test"); // $ExpectError
const allure = new Allure();
allure.startSuite("suite");
allure.startCase("case");
allure.startCase("case", 123456789);
allure.endCase("passed");
allure.endCase("pending");
allure.endCase("skipped");
allure.endCase("failed");
allure.endCase("broken", 1232131232);
allure.endCase("error"); // $ExpectError
allure.startStep("error");
allure.endStep("error"); // $ExpectError
allure.setDescription("description");
allure.addAttachment("image", {}, "image/jpeg");
allure.pendingCase("pending");
allure.endSuite();

109
types/allure-js-commons/index.d.ts vendored Normal file
View File

@@ -0,0 +1,109 @@
// Type definitions for allure-js-commons 0.0
// Project: https://github.com/allure-framework/allure-js-commons
// Definitions by: Denis Artyuhovich <https://github.com/zaqqaz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
declare class Allure {
constructor();
setOptions(options: Allure.Options): void;
getCurrentSuite(): Allure.Suite;
getCurrentTest(): Allure.Test;
startSuite(suiteName: string, timestamp?: number): void;
endSuite(timestamp?: number): void;
startCase(testName: string, timestamp?: number): void;
endCase(status: Allure.Status, err?: {}, timestamp?: number): void;
startStep(stepName: string, timestamp?: number): void;
endStep(status: Allure.Status, timestamp?: number): void;
setDescription(description: string, timestamp?: number): void;
addAttachment(attachmentName: string, buffer: any, type: string): void;
pendingCase(testName: string, timestamp?: number): void;
}
export = Allure;
export as namespace Allure;
declare namespace Allure {
interface Options {
targetDir: string;
}
type Status = "passed" | "pending" | "skipped" | "failed" | "broken";
enum TYPE {
TEXT = "text",
HTML = "html",
MARKDOWN = "markdown"
}
class Suite {
constructor(name: string, timestamp?: number);
end(timestamp?: number): void;
hasTests(): boolean;
addTest(test: Test): boolean;
toXML(): string;
}
class Test {
constructor(name: string, timestamp?: number);
setDescription(description: string, type: TYPE): void;
addLabel(name: string, value: string): void;
addParameter(kind: any, name: string, value: string): void;
addStep(step: Step): void;
addAttachment(attachment: Attachment): void;
end(status: Status, error: Error, timestamp?: number): void;
toXML(): string;
}
class Description {
constructor(value: string, type: TYPE);
toXML(): string;
}
class Step {
constructor(name: string, timestamp?: number);
addStep(step: Step): void;
addAttachment(attachment: Attachment): void;
end(status: Status, error: Error, timestamp?: number): void;
toXML(): string;
}
class Attachment {
constructor(title: string, source: any, size: number, mime: string);
addStep(step: Step): void;
addAttachment(attachment: Attachment): void;
end(status: Status, error: Error, timestamp?: number): void;
toXML(): string;
}
}

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",
"allure-js-commons-tests.ts"
]
}

View File

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