Calling variables from .env file #211
-
Hello, I need to use different variables for different environments. I have this solution which is working, but is not suitable for more different variables: Variables are saved in .env file APP_USERNAME = value
APP_PASSWORD = value Step is defined in steps.js file When('login with valid credentials', {timeout: 30000}, function () {
spec = pactum.spec();
spec.post("/auth/login");
spec.withJson({
username: process.env.APP_USERNAME,
password: process.env.APP_PASSWORD
})
}); Call the step in test.feature file But, I need a way to call .env variables directly from test.feature file. Is there any way to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Update your step definition to accept custom username and password When(/^login with (.*) and (.*)$/, {timeout: 30000}, function (username, password) {
spec = pactum.spec();
spec.post("/auth/login");
spec.withJson({
username: process.env[username],
password: process.env[password]
})
}); |
Beta Was this translation helpful? Give feedback.
Update your step definition to accept custom username and password