Skip to content

BeforeFeature/Scenario/Step hooks #19

@ghost

Description

Hey, seems I can't find these for the preprocessor, might be me who can't search properly.

Basically I would like to be able to do some tracability for my tests when they are running against the backend, where I would like to attach the feature name and scenario name in the headers of cy.request (the BeforeStep is mostly for completeness).

So I'd like to be able to do:

let featureName: string = ""
let scenarioName: string = ""

BeforeFeature((event, callback) => {
    featureName = event.getPayloadItem('feature')
})

// similar for Scenario

Cypress.Commands.overwrite('request', function(originalFn, ...restParameters) {
    if (restParameters.length === 1) {
        restParameters[0].headers['x-correlation-id'] = `accept-test-${featureName}-${scenarioName}`
    }

    return originalFn.apply(this, restParameters)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions