Is there a way how to set my Cucumber-js to ignore uncaught errors - cucumberjs

I am setting up the Cucumber-js (I have migrated Testcafe into Cucumber framework) project which runs well on Chrome and Edge browser. By running on IE 11, the console error causes failing my test scenarios. How to specify in Cucumber-js to ignore uncaught errors? The issue is not reproducible by manual handling or on another browsers as I already mentioned (issue caused by different JQuery version).

I have specified it in
return runner
.src('./test.js')
.screenshots('reports/screenshots/', true)
.browsers(browser)
.run({skipJsErrors: true})
.catch(function(error) {
console.error(error);
});
})
Which works well for me

CucumberJS has no interaction with a browser. It is selenium or protractor that does that kind of operation so it may be better to ask in those StackOverflow communities. I will say that I have not ever seen a browser console error causing browser controlled tests to fail (unless purposefully implemented that way).

Related

Error when testingElasticSearch apps via Cypress resulting in results not being populated - "[useElasticsearch] incorrect header check"

We use Elastic Search throughout most of our app, and up until today, we've never had issues with testing those features via Cypress. One feature in our app is a calendar tool that populates a list with appointment dates and times. When accessing this calendar tool manually via Chrome, the list correctly populates without issue. When opening this tool during a Cypress spec, and ONLY during a Cypress spec, the results fail to load. The console spits out an error that just says "[useElasticsearch] incorrect header check" with no other information. In checking the network tab, we can confirm that the ES query is performed and returns results successfully, but the page is not updated with those results.
Note that this is NOT the result of a cy.request(), this error occurs through standard UI navigation. This issue, as I mentioned, ONLY occurs when testing via Cypress. Due to this, we are hesitant to make changes to the backend of the app, since it works perfectly fine in all other scenarios. This has been reproduced on Cypress versions 5.1.0, 6.1.0, 7.1.0, and 8.0.0. This has also been reproduced in Cypress when using the Chrome, Electron, and headless browsers.
Has anybody else encountered this issue?

Why does running Cypress on a React/GraphQL app return network errors when normal browsing doesn't?

I have a React/apollo client and an apollo/neo4j backend application based on GRANDStack.
My React app runs on localhost:3000 and my GraphQL on localhost:4001/graphql, and they communicate without fail. All is working well in the app (with CORS enabled), but I wanted to implement testing with Cypress.
Should I expect Cypress to be able to observe the flow between React and GraphQL without error? Or is this beyond its capability?
What I've tried:
I set up Cypress and ran the following test:
it("Opens myPlan.", function() {
cy.visit("localhost:3000/myPlan");
cy.wait(6000);
});
At first cypress setup, my site loaded. One of the first things that the app does is graphql query a few values, and create a dropdown box based on those values. While this and all other graphql requests work fine in the browser, I get "{"graphQLErrors":[],"networkError":{"name":"ServerParseError","response":{},"statusCode":404,"bodyText":""},"message":"Network error: Unexpected end of JSON input"}" errors in cypress for the same code.
Presumably, the problem was because there are 2 endpoints, and cy.visit only allows one. I tried disabled ChromeWebSecurity and tried an "Access-Control-Allow-Origin-master" plugin.
Edit: I found someone that knew Cypress, and they suggested adding:
"proxy": "http://localhost:4001/",
to my react client config. This avoids the multi-port issues, and Cypress works.
Edit: I found someone that knew Cypress, and they suggested adding:
"proxy": "http://localhost:4001/",
to my react client config. This avoids the multi-port issues, and Cypress works.

Firefox seems to fail on registering a ServiceWorker for Push Notifications?

Firefox seems to fail on registering a ServiceWorker for Push Notifications, with an error "InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable", but the code works in Chrome and Edge, and appears to be compliant with the examples online and the spec.
I've thrown an example up on one of my test sites, https://wiegandtech.net/ - visiting it in Chrome will prompt for permission and then opt-in successfully, sending the info to the server. But Firefox prompts, doesn't complete the registration, and doesn't fire any error or throw anything into the console. When I try to debug, it seems to never return from navigator.serviceWorker.ready.then call - I debug in and reg is undefined, even though the promise says it shouldn't be. I can find no reason why this is failing. I do see in Fiddler that FF gets the worker file, so it appears to be starting the call, but never finishing? The worker is valid JavaScript, as far as I can tell. Does anyone have any documentation on how Firefox's implementation is different from Chrome's/the spec?
Firefox requires the ServiceWorker's URL to end in .js - I was using an ASP.Net site and returning javascript but through my own controller. When I just give it the URL for the .js file itself, it now works. Would file a bug, but too non-trivial to setup a site given that ServiceWorkers require a real life site to troubleshoot, and their source code doesn't appear to be on github.

How can I log javascript errors with Poltergeist/Capybara/Rspec?

I'm using Rspec/Capybara with Poltergeist as a driver to write tests for some large web applications.
My issue is that I would like to record the messages that appear on the console, but so far I've been unable to do so.
I am aware of the options js_errors and phantomjs_logger, but I have had some issues with them:
if I set js_errors: false, the file I specify in phantomjs_logger stays empty;
if I set js_errors: true, console.log messages are logged in the file specified in phantomjs_logger, but then almost all my specs fail because of
javascript errors that may not even be relevant to the navigation example I'm testing.
Any idea on how I can save the console messages while not breaking specs on every js error?
CLARIFICATION:
I have no control over the development, my task is to check the stability of the whole stack of the applications in the various environments, accessing from the front-end, so clearing out all the javascript errors is out of the question. The specs I'm writing are also supposed to ignore javascript errors if they don't impair the usage of the interface.
You can't. The PhantomJS client catches javascript error messages and adds them to an array. Then when a command completes, if js_errors == true, that array is checked and if not empty the javascript errors are returned and trigger an error in the test. There is no other API in poltergeist for accessing those errors. It sounds like you need to have a discussion with your manager about the wisdom of just ignoring JS errors if they apparently don't impair usage - it's a potentially dangerous development practice

Selenium testing with DoubleClick AD on page

I am currently writing a selenium test case for a page which has doubleClick ad integrated in header and footer.
Selenium works perfectly fine until it comes to test this page, and test breaks with following issue.
Exception class=[java.lang.IllegalArgumentException]
com.gargoylesoftware.htmlunit.ScriptException: Exception invoking Window.getComputedStyle() with arguments [Text, String]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:601)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
I wonder any one has gone through issue.
Here is my stack
WebDrive : Firefox
HtmlUnit 2.12
Selenium-htmlunit-driver-2.33.0
I think css getting pulled by doubleclick on runtime causing the issue.
Any help in this regard will be helpful.

Resources