Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeforeFeature/Scenario/Step hooks #19

Open
ghost opened this issue May 6, 2020 · 0 comments
Open

BeforeFeature/Scenario/Step hooks #19

ghost opened this issue May 6, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented May 6, 2020

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)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants