How we can shorten this:
And match response !contains { foo: '#notnull' }
And match responseHeaders !contains { foo: '#notnull' }
Sorry if we didn't find a response in the official tuto
I looked at your comment and if you ask my honest opinion, you are expecting too much from a JSON assertion framework. Really ? This is what you are most worried about ?
So the short answer is Karate does not support what you are expecting, directly.
That said - you can write a custom JavaScript (or Java) function in Karate to get the values of the response and the responseHeaders and then do whatever you want. I leave that as an exercise to you to figure out.
Related
Hello could someone help me how to remove the additional "{ and "} on the request upon using JSR223 PreProcessor, This is the syntax I use to generate the request below. Your response is highly appreciated. Thank you so much.
Screenshot:
Expected Result:
"metrics": {
"com.cixsoft.agent.metric.NetworkMetric": "NetworkMetric.json",
"com.cixsoft.agent.metric.ProcessInfoMetric": "ProcessInfoMetric.json",
"com.cixsoft.agent.metric.CpuMetric": "CpuMetric.json"
},
Actual Result:
"metrics": {
"{ -<< Remove this open curly braces
"com.cixsoft.agent.metric.NetworkMetric": "NetworkMetric.json",
"com.cixsoft.agent.metric.ProcessInfoMetric": "ProcessInfoMetric.json",
"com.cixsoft.agent.metric.CpuMetric": "CpuMetric.json"
"} -<< -<< Remove this close curly braces
},
Don't post code as image
Give us a minimal reproducible example
Follow other recommendations from How do I ask a good question? article
For example we need to know:
The value of the agentSimUserMetric variable
How exactly you're using this userMetric variable
Looking at my crystal ball I see that you have something like:
"metrics" : {
${userMetric}
}
while you need to have just
"metrics" : ${userMetric}
so I'm 99.9% sure that it's you who is adding these curly braces and asking us for a piece of advice regarding how to remove them sounds kind of weird.
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy: What Is Groovy Used For?
I have a question regarding Cypress assertions, just recently start playing with this testing platform, but got stuck when the URL returns a random number as shown below.
/Geocortex/Essentials/REST/sites/SITE?f=json&deep=true&token=SK42f-DZ_iCk2oWE8DVNnr6gAArG277W3X0kGJL1gTZ7W5oQAAV9iC4Zng4mf0BlulglN-10NK&dojo.preventCache=1575947662312
As you can see token is random and dojo.preventCache is also a random string. I want to detect this url and check if deep=true regardless the token number, but I don't know how to achieve this.
cy.location('origin', {timeout: 20000}).should('contain', '/Geocortex/Essentials/REST/sites/SITE?f=json&deep=true&token=**&dojo.preventCache=**');
Anyone any idea?
You can check both the path and query like this (note that cy.location('origin') doesn't yield neither pathname nor query from your original question, so I'm using cy.url()):
cy.url()
.should('contain', '/Geocortex/Essentials/REST/sites/SITE')
.should('contain', 'deep=true');
or check each separately:
cy.location('pathname').should('contain', '/Geocortex/Essentials/REST/sites/SITE');
cy.location('search').should('contain', 'deep=true');
or, use a custom callback in which you do and assert whatever you want:
cy.url().should( url => {
expect(/* do something with url, such as parse it, and access the `deep` prop */)
.to.be.true;
});
Where is the documentation for /api/storefront/orders/*?
I was expecting to find it on this page.
https://developer.bigcommerce.com/api-docs/cart-and-checkout/working-sf-apis
Specifically, the documentation that would cover /api/storefront/orders/:order-id
and cover the valid inputs to the querystring. I know you can pass include, with one or more of the values as a comma separated string
payments
lineItems.physicalItems.socialMedia
lineItems.physicalItems.options
lineItems.digitalItems.socialMedia
lineItems.digitalItems.options
Edit
The checkout stencil context object used on theme\templates\pages\order-confirmation.html has this schema
{
"order_confirmation_content": "goes in the body",
"checkout_head": "goes in the head",
"order": {
"id": 206
},
"header_image": "for an img src attribute"
}
The documentation for the storefront orders API can be found here:
https://developer.bigcommerce.com/api-reference/orders/storefront-orders-api/order/ordersbyorderidget
However, as you mentioned, there are a few query parameters that are undocumented. Those are not officially supported, and they might be subject to change in the future. This is a case where our position is to hold off on documenting the API parameters until we've determined long-term support. Hope that helps to provide some context!
Hi i need some help for this issue, I need to run:
exports.someFunction = function () {
// i need call a route like this.
app.route('api/getdata');
};
I need call some route in express function. How can I do it?
I'm assuming that /api/getdata returns some sort of data (in a format like JSON) you need to use. In that case, it is pretty simple, just use Node's excellent unirest library. I find Node's http a little advanced for this case. Assuming that this is a GET request, it would look something along the lines of:
unirest.post('http://example.com/api/getdata').end(function (response) {
console.log(response.body);
});
Of course, you can use Node's http.get if you wanted or any other HTTP library you like.
Recently we have added Lucene(2.4.1) support to our application which worked with Jackrabbit(1.6.2). We have done all like it was described in jackrabbit tutorial. And all works almost fine. But I noticed some strange behavior and can't find any docs about it. I decided to ask you about it.
For example: I have following text in Node(jcr:content) in jcr:data property
The quick brown fox jumps over the lazy dog
!##$%^&
travmik!
tra!vmik
My XPath query is the following:
String query = "root/element(*,my:documentBody)
[jcr:contains(*/*/element(*),'*" + param +"*')]";
Then I try to search:
"q", "qu", "qui", "quic", "quick", "k", "ck", "ick", "uick", "quick brown fox", "quick fox", "tra", "travmik", "mik" - all found ok
"tra!vmik", "travmik!", "!##$" - nothing
And, yes I escaped all special characters from this.
What did I do wrong?
P.s. I have one more question - in Lucene docs says that "You cannot use a * or ? symbol as the first character of a search", but I use and it works. Why?
I found the problem. It was some misunderstanding with Extractors which are used in jackrabbit for indexing content. I don't want to go into details, but can say that this piece of code from one of Extractors is the cause of all my problems:
if (!Character.isLetterOrDigit(c)) {
if (!space) {
space = true;
buffer.append(' ');
continue;
}
continue;
}
If someone is interested in this - I can explain in greater detail.