Reputation: 31
I am trying to below code using Intellij and Karate but getting an error message.
Code below
Feature: sample karate test script
for help, see: https://github.com/intuit/karate/wiki/IDE-Support
Scenario: create a user and then get it by id
* def user =
"""
{
ethereum {
smartContractEvents(options: {desc: "date.date"}, smartContractAddress: {is: "0x00000000219ab540356cbb839cbe05303d7705fa"}, date: {since: "2019-01-01", till: null}) {
date {
date: startOfInterval(unit: day)
}
smartContractEvent {
__typename
name
}
times: count
uniqueCallers: count(uniq: callers)
}
}
}
"""
Given url 'https://graphql.bitquery.io'
And request user
When method get
Then print response
when u try to run the code, I am getting the below error message
test.feature:6 - net.minidev.json.parser.ParseException: Unexpected token ) at position 181.
01:12:04.375 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<fail>> feature 1 of 1: src/test/java/examples/users/test.feature
Upvotes: 1
Views: 230
Reputation: 31
Got the answer,
right way is to use query
Feature: sample karate test script
Background:
* url 'https://graphql.bitquery.io'
# this live url should work if you want to try this on your own
# * url 'https://graphql-pokemon.now.sh'
Scenario: simple graphql request
# note the use of text instead of def since this is NOT json
Given text query =
"""
{
ethereum {
dexTrades(date: {is:"2020-11-29"} options: {limit: 10}
baseCurrency: {is: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}
quoteCurrency:{is: "0xdac17f958d2ee523a2206206994597c13d831ec7"}
){
baseCurrency {
symbol
address
}
baseAmount
quoteCurrency {
symbol
address
}
quoteAmount
quotePrice
}
}
}
"""
And request { query: '#(query)' }
When method post
Then print response
Upvotes: 1