Last active
January 11, 2019 14:57
-
-
Save korobochka/3c7c6b67f7745ac2a845f6ed362e5026 to your computer and use it in GitHub Desktop.
Allure 2 Typescript step decorators
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
import { allure } from "../conf/protractorConf"; // export AllureInterface from the config file with onPrepare etc. | |
export function step(description: string): (...args: any[]) => TypedPropertyDescriptor<any> { | |
return (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => { | |
const original = descriptor.value; | |
descriptor.value = function(...args: any[]) { | |
// todo you can inject args into the description here if needed | |
return allure.step(description, () => { | |
console.log(`Running step: ${description}`); | |
return original.apply(this, args); | |
}); | |
}; | |
return descriptor; | |
}; | |
} | |
// don't forget to set "compilerOptions": { "experimentalDecorators": true } in `tsconfig.json` |
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
import { step } from "decorators"; | |
class Page { | |
@step("Navigating to main page") | |
public go() { | |
return browser.get("http://example.com/"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment