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

Cannot refer to the stored value in request defaults #137

Closed
ASaiAnudeep opened this issue Apr 12, 2022 Discussed in #130 · 3 comments · Fixed by #139
Closed

Cannot refer to the stored value in request defaults #137

ASaiAnudeep opened this issue Apr 12, 2022 Discussed in #130 · 3 comments · Fixed by #139
Labels
bug Something isn't working question Further information is requested

Comments

@ASaiAnudeep
Copy link
Member

Discussed in #130

Originally posted by martynaol March 28, 2022
I want to store the access token to use this value later. I have :

const pactum = require('pactum');
const { Given, When, Then, Before } = require('@cucumber/cucumber');

Before(async () => {
    await pactum
      .spec()
      .post('/credentials')
      .withForm({
        username: email,
        password: passw,
      })
      .expectStatus(200)
      .stores('token', 'access_token');
})
    pactum.request.setDefaultHeaders('Authorization', 'Bearer $S{token}');

syntax '$S{token}' is a string, the next request is with "headers": {
"Authorization": "Bearer $S{token}"
},

what am I doing wrong?

@ASaiAnudeep ASaiAnudeep added bug Something isn't working question Further information is requested labels Apr 12, 2022
@maxckelly
Copy link

Getting the same issue. Did you find a solution?

@ASaiAnudeep
Copy link
Member Author

This is fixed. Please use the latest version of pactum.

@jd4u
Copy link

jd4u commented Apr 24, 2023

I request to recheck, as with v3.4.0 (latest), the bug seems to exists. (initially tried with v3.3.3, then upgraded today)

Read more in discussion 130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants