Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@binding()
class BaseSteps {
elementService: ElementService;
variableService: VariableService;
lifeCycleHooks: IHooks;
defaultElementTimeout: number;
constructor() {
this.elementService = ElementService.GetInstance();
this.variableService = VariableService.GetInstance();
this.lifeCycleHooks = new Hooks();
this.defaultElementTimeout = 10000;
}
@before()
public beforeEveryScenarios(): void {
this.lifeCycleHooks.beforeScenario();
}
@after()
public afterEveryScenario(): void {
this.lifeCycleHooks.afterScenario();
}
// @after()
// public afterAllScenarios(scenario): void {
// if (scenario.status === 'failed') {
// let world = this;
// browser.takeScreenshot().then(function (png) {
// var decodedImage = new Buffer(png.replace(/^data:image\/(png|gif|jpeg);base64,/, ''), 'base64');
// ScenarioContext.attach(decodedImage, 'image/png');
"use strict";
import * as tmp from "tmp";
import { binding, before } from "cucumber-tsflow";
import { TypeScriptWorkspace, WorkspaceInfo } from "./TypeScriptWorkspace";
@binding([TypeScriptWorkspace])
class Hooks {
constructor(protected workspace: TypeScriptWorkspace) {
}
@before()
public async beforeScenario(): Promise {
let tempDirInfo = await this.createTemporaryDirectoryAsync();
console.log(`Created temporary workspace '${tempDirInfo.path}'`);
this.workspace.setWorkspace(tempDirInfo);
}
/**
* An asynchronous wrapper around tmp.dir().
*/
private async createTemporaryDirectoryAsync(): Promise {
return new Promise((resolve, reject) => {
tmp.dir({ unsafeCleanup: true }, (error, path, cleanupAction) => {
if (error) reject(error);