Reputation: 116
I am new to the Karate DSL framework. In all the demo examples given in https://github.com/intuit/karate/tree/master/karate-demo , the url is given as demoBaseUrl
.
From where is this URL obtained? If it is getting it from karate-config.js then how is it used in the feature file and, how to define that variable in karate-config.js?
Will the karate-config.js file be executed if we run any test suite and will those variables then be used in the feature files
Below is the code which am I using
Feature: Simple users test script
Background:
* url baseUrl
Scenario: get all users and validate the response
Given path 'users'
When method get
Then status 200
function(){
var baseUrl= 'https://jsonplaceholder.typicode.com';
}
After execution this is exception I am getting:
Scenario: [1:6]get all users and validate the response
Test 1 : * url baseUrl 0.004878
-unknown-:4 - javascript evaluation failed: baseUrl, ReferenceError: "baseUrl" is not defined in <eval> at line number 1
Upvotes: 0
Views: 3046
Reputation: 58058
Please take the help of someone who knows JS. Your config file should be:
function(){ return { baseUrl: 'https://jsonplaceholder.typicode.com' } }
Upvotes: 1