Before all my tests (running in jasmine under protractor) I have to login to my system and if login fails I should not run any test. But even when I use proccess.exit (which is node feature to halt program execution), tests are still executed and all failed .
beforeAll(function(done){
mainPage.resize();
loginPage.login(env.regularUser).then(function(){
mainPage.navigate();
mainPage.waitLoading();
done();
}, function(){
process.exit(1);
});
});
How can I prevent tests execution in beforeAll block?
If I understand correctly, this is the same or a related problem to:
Does jasmine-node offer any type of "fail fast" option?
Feature Request - fail-fast option
Bail on first failure
--fail-fast CLI option
Quitting on first failure
In other words, this is something a testing framework (in this case jasmine) should have. At the moment, this is an open feature request.
As a current workaround, use jasmine-bail-fast third-party package.
Related
In my Cypress tests, I create some data in before block and then my test script is run that locates in it block. I checked business side flow and it seems like there is no error about app side. I just want to understand that why my test's result is success after second attempt. Does Cypress has this kind of solution to handle an error maybe?
Cypress has the ability to automatically retry any failed tests. I would check your Cypress configuration's value for retries.openMode.
I have cypress UI tests running remotely. Our authentication team has recently made a change that redirects the page twice, previously only once. This change has caused my tests to fail at cy.visit('/') with error "Exceeded maxRedirects. Probably stuck in a redirect loop https://mybetawebsite/redirect=signin&redirect=signin"
When I asked them about this erorr, they told me to follow the redirect a second time.
I know cy.visit follows redirects
(https://docs.cypress.io/api/commands/visit#Redirects) , but it does only once or multiple times?
Previously, when my tests were passing, I could see 302(redirection) at cy.visit (to different url for auth) and test used to continue and pass.
in my cypress.json,
baseUrl: https://mybetawebsite
How do I handle second redirect?
As a part of my CI pipeline, I am testing my frontend using cypress. I run cypress run to test. One test is failing due to failed fetch request. How can I see detailed information about that fetch? So far I could only see which fetch failed from the video recording and screenshots of the test.
Cypress is built using the debug module. That means you can receive helpful debugging output by running Cypress with this turned on.
DEBUG=cypress:* npx cypress run
In case you want specific detailed Debug Logs, You can write something like:
DEBUG=cypress:network:*,cypress:net-stubbing* npx cypress run
Cypress is built from multiple packages, each responsible for its own logging: server, reporter, driver, command line, etc. Each package writes debug logs under a different source. You can find the list of log sources from here.
Do you know the failed url? If so, intercept it.
cy.intercept('/url', (req) => {
req.on('response', (res) => {
console.log(res)
})
})
You may have difficulty with nested details, if so
console.log(JSON.stringify(res))
or
cy.writeFile('cypress/debug/fetch.json', res))
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).
I have a test suite of around 1000 test cases, but sometimes if one test case fails due to some unclosed popup window, all of the subsequent test cases will also fail because the popup modal will not allow protractor to interact with page elements.(My app is that way)
So I want to create some condition such as i will refresh the page if a test case fails or I will go to my homepage link if test case fails as all tc's start from same starting point.
This will prevent all my subsequent test cases from failing. This method was called recovery scenario in QTP/UFT days.
I was also facing these kind of issue that if one test case fails subsequent all test cases will fail,Not sure if there is any recovery scenarios available in protractor but I am using before all, after all, before each and after each to start my each test from a clean state. I have added a helper function to navigate to Home page and I call every time this function from before each.
this is helpful link