How to use the cucumber-tsflow.before function in cucumber-tsflow

To help you get started, we’ve selected a few cucumber-tsflow examples, based on popular ways it is used in public projects.

github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
@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');
github timjroberts / cucumber-js-tsflow / cucumber-tsflow-specs / src / support / Hooks.ts View on Github external
"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<void> {
        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<WorkspaceInfo> {
        return new Promise<WorkspaceInfo>((resolve, reject) => {
            tmp.dir({ unsafeCleanup: true }, (error, path, cleanupAction) => {
                if (error) reject(error);

cucumber-tsflow

Provides 'specflow' like bindings for CucumberJS 7.0.0+ in TypeScript 1.7+.

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis