@mysterious-belgium-25713 @gray-kilobyte-89541 one of our developers solved our script problem. Here is his finding and updated version. And it is working. Thanks a lot for all your help and information regarding our issue. It helps! I posted the solution here in case anyone else has similar problem.
The test is failing because it finds the stn_trk.gif request that is being made for the ldt=BIDS request.
So, the test is looking for the first stn_trk.gif request that comes to it, that happens to be the ldt=BIDS for some reason even though it isn't the first request made (maybe cypress handles the network requests as a stack, so the last request made is the first thing it checks?), and then we are checking if it has cmd in it. Which it doesn't, because that isn't a cmd log.
What I am able to do is change the test to this:
//DP-4833 -- Automation: QA - Network Calls going to
https://s2l.sendtonews.com/stn_trk.gif▾
///
//cmd=PRE_INIT
describe('Window', () => {
beforeEach(() => {
})
it.only('Validate the field "cmd=PRE_INIT" in the service
https://s2l.sendtonews.com/stn_trk.gif▾
', () => {
cy.visit('https://peterdev.sendtonews.com/demo/QA_test_player.html')
cy.intercept
({
method: "POST",
query: { cmd: "PRE_INIT" },
hostname: "s2l.sendtonews.com"
}).as('cmd')
cy.wait('@cmd').its('request.url').then((req)=>{
expect(req).to.include('cmd')
})
})
})
So that we look and wait for the PRE_INIT request specifically, and then check if it has cmd in the URL (which of course it does) and this test succeeds.