forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tracking doc: rewrite
@wdio/allure-reporter
package into Typescript (…
- Loading branch information
Showing
37 changed files
with
3,489 additions
and
3,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
declare namespace AllureReporter { | ||
type StepStatus = 'passed' | 'failed' | 'broken' | 'canceled' | 'skipped' | ||
|
||
function addFeature( | ||
featureName: string | ||
): void; | ||
function addLabel( | ||
name: string, | ||
value: string | ||
): void; | ||
function addSeverity( | ||
severity: string | ||
): void; | ||
function addIssue( | ||
issue: string | ||
): void; | ||
function addTestId( | ||
testId: string | ||
): void; | ||
function addStory( | ||
storyName: string | ||
): void; | ||
function addEnvironment( | ||
name: string, | ||
value: string | ||
): void; | ||
function addDescription( | ||
description: string, | ||
descriptionType: string | ||
): void; | ||
function addAttachment( | ||
name: string, | ||
content: any, | ||
mimeType?: string | ||
): void; | ||
function startStep( | ||
title: string | ||
): void; | ||
function endStep( | ||
status?: StepStatus | ||
): void; | ||
function addStep( | ||
title: string, | ||
attachmentObject?: object, | ||
status?: string | ||
): void; | ||
function addArgument( | ||
name: string, | ||
value: string | ||
): void; | ||
} | ||
|
||
declare module "@wdio/allure-reporter" { | ||
export default AllureReporter | ||
} |
100 changes: 100 additions & 0 deletions
100
packages/wdio-allure-reporter/src/@types/allure-js-commons.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Allure is providing its own types in v2, but there's too many changes, | ||
// so this is temporarily copied here to customize typings with allure 1 | ||
// Type definitions for allure-js-commons 0.0 | ||
// Project: https://github.com/allure-framework/allure-js | ||
// Definitions by: Denis Artyuhovich <https://github.com/zaqqaz> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.7 | ||
declare module 'allure-js-commons/beans/step' { | ||
class Step {} | ||
export = Step | ||
} | ||
|
||
declare module 'allure-js-commons' { | ||
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; | ||
namespace Allure { | ||
interface Options { | ||
targetDir: string; | ||
} | ||
|
||
// type Status = "passed" | "pending" | "skipped" | "failed" | "broken"; | ||
type Status = 'passed' | 'pending' | 'skipped' | 'failed' | 'broken' | 'canceled'; | ||
|
||
enum TYPE { | ||
TEXT = 'text', | ||
HTML = 'html', | ||
MARKDOWN = 'markdown' | ||
} | ||
|
||
class Suite { | ||
currentStep: Allure.Step; | ||
testcases: string[]; | ||
name: string; | ||
|
||
constructor(name: string, timestamp?: number); | ||
|
||
end(timestamp?: number): void; | ||
hasTests(): boolean; | ||
addTest(test: Test): boolean; | ||
toXML(): string; | ||
} | ||
|
||
class Test { | ||
steps: Allure.Step[]; | ||
name: string; | ||
|
||
constructor(name: string, timestamp?: number); | ||
|
||
setDescription(description: string | undefined, 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 { | ||
attachments: Attachment[]; | ||
|
||
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; | ||
} | ||
} | ||
} |
42 changes: 22 additions & 20 deletions
42
...wdio-allure-reporter/src/compoundError.js → ...wdio-allure-reporter/src/compoundError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
function indentAll(lines) { | ||
return lines.split('\n').map(x => ' ' + x).join('\n') | ||
} | ||
|
||
/** | ||
* An error that encapsulates more than one error, to support soft-assertions from Jasmine | ||
* even though Allure's API assumes one error-per test | ||
*/ | ||
export default class CompoundError extends Error { | ||
constructor(...innerErrors) { | ||
const message = ['CompoundError: One or more errors occurred. ---']. | ||
concat(innerErrors.map(x => { | ||
if (x.stack) return `${indentAll(x.stack)}\n--- End of stack trace ---` | ||
return ` ${x.message}\n--- End of error message ---` | ||
})).join('\n') | ||
|
||
super(message) | ||
this.innerErrors = innerErrors | ||
} | ||
} | ||
function indentAll(lines: string) { | ||
return lines.split('\n').map(x => ' ' + x).join('\n') | ||
} | ||
|
||
/** | ||
* An error that encapsulates more than one error, to support soft-assertions from Jasmine | ||
* even though Allure's API assumes one error-per test | ||
*/ | ||
export default class CompoundError extends Error { | ||
public innerErrors: Error[] | ||
|
||
constructor(...innerErrors: Error[]) { | ||
const message = ['CompoundError: One or more errors occurred. ---']. | ||
concat(innerErrors.map(x => { | ||
if (x.stack) return `${indentAll(x.stack)}\n--- End of stack trace ---` | ||
return ` ${x.message}\n--- End of error message ---` | ||
})).join('\n') | ||
|
||
super(message) | ||
this.innerErrors = innerErrors | ||
} | ||
} |
87 changes: 44 additions & 43 deletions
87
...ges/wdio-allure-reporter/src/constants.js → ...ges/wdio-allure-reporter/src/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
const PASSED = 'passed' | ||
const FAILED = 'failed' | ||
const BROKEN = 'broken' | ||
const PENDING = 'pending' | ||
const CANCELED = 'canceled' | ||
const SKIPPED = 'skipped' | ||
|
||
const testStatuses = { | ||
PASSED, | ||
FAILED, | ||
BROKEN, | ||
PENDING | ||
} | ||
|
||
const stepStatuses = { | ||
PASSED, | ||
FAILED, | ||
BROKEN, | ||
CANCELED, | ||
SKIPPED | ||
} | ||
|
||
const events = { | ||
addLabel: 'allure:addLabel', | ||
addFeature: 'allure:addFeature', | ||
addStory: 'allure:addStory', | ||
addSeverity: 'allure:addSeverity', | ||
addIssue: 'allure:addIssue', | ||
addTestId: 'allure:addTestId', | ||
addEnvironment: 'allure:addEnvironment', | ||
addDescription: 'allure:addDescription', | ||
addAttachment: 'allure:addAttachment', | ||
startStep: 'allure:startStep', | ||
endStep: 'allure:endStep', | ||
addStep: 'allure:addStep', | ||
addArgument: 'allure:addArgument' | ||
} | ||
|
||
const mochaEachHooks = ['"before each" hook', '"after each" hook'] | ||
const mochaAllHooks = ['"before all" hook', '"after all" hook'] | ||
const linkPlaceholder = '{}' | ||
|
||
export { testStatuses, stepStatuses, events, mochaEachHooks, mochaAllHooks, linkPlaceholder } | ||
import Allure from 'allure-js-commons' | ||
|
||
export const PASSED = 'passed' | ||
export const FAILED = 'failed' | ||
export const BROKEN = 'broken' | ||
export const PENDING = 'pending' | ||
export const CANCELED = 'canceled' | ||
export const SKIPPED = 'skipped' | ||
|
||
const testStatuses: Record<string, Allure.Status> = { | ||
PASSED, | ||
FAILED, | ||
BROKEN, | ||
PENDING | ||
} as const | ||
const stepStatuses: Record<string, Allure.Status> = { | ||
PASSED, | ||
FAILED, | ||
BROKEN, | ||
CANCELED, | ||
SKIPPED | ||
} as const | ||
|
||
const events = { | ||
addLabel: 'allure:addLabel', | ||
addFeature: 'allure:addFeature', | ||
addStory: 'allure:addStory', | ||
addSeverity: 'allure:addSeverity', | ||
addIssue: 'allure:addIssue', | ||
addTestId: 'allure:addTestId', | ||
addEnvironment: 'allure:addEnvironment', | ||
addDescription: 'allure:addDescription', | ||
addAttachment: 'allure:addAttachment', | ||
startStep: 'allure:startStep', | ||
endStep: 'allure:endStep', | ||
addStep: 'allure:addStep', | ||
addArgument: 'allure:addArgument' | ||
} | ||
|
||
const mochaEachHooks = ['"before each" hook', '"after each" hook'] | ||
const mochaAllHooks = ['"before all" hook', '"after all" hook'] | ||
const linkPlaceholder = '{}' | ||
|
||
export { testStatuses, stepStatuses, events, mochaEachHooks, mochaAllHooks, linkPlaceholder } |
Oops, something went wrong.