I've been using this React CSSTransition component:
http://reactcommunity.org/react-transition-group/css-transition
I'm adding Cypress tests. CSSTransition callbacks such as onExited and onEntered always run when I'm walking through my app in a regular browser (Chrome). But in the version of Chrome being automated by Cypress, these callbacks are either never called or never executed.
I wonder if anyone else has run into this issue, or has some ideas about why it's happening, and how to fix it, or work around it.
It had to do with cy.clock. If you use cy.clock earlier in the test, you need to use cy.tick, or
cy.clock().then((clock) => {
clock.restore()
})
Related
I need a solution. I have a lot of spec files with tests and after each of them I use cy.logout command.
I want to avoid write this logout function each time and want it global.
But when I tried add this function in index.js file it was called at the beginning of each test because index.js works perfect only with beforeEach but not with afterEach.
What should I do?
Thanks
[EDIT]
I just find out that problem was provoke by my mistake in code in second test, so the only problem I have with Cypress is that I dont get any information where I made my mistake because Cypress show me that problem is afterEach hook and nothing else.
If you want your logout runs only once for each of your spec file, and not after each of your test within the file, you must use after instead of afterEach.
after(() => {
cy.logout()
})
Using afterEach() or beforeEach() block in support/index.js. Refer below page to run a "global" hook
https://filiphric.com/cypress-basics-before-beforeeach-after-aftereach
We are in a process of migrating existing Protractor scripts(with Jasmine Framework) to Cypress.
I would like to know if we can use the Jasmine in Cypress also. As, Cypress by default uses Mocha.., so need a clarification if we can install Jasmine dependences along with Cypress to define the tests with Framework.
I don't think so. Cypress modifies/patches the Mocha hooks like beforeEach() and also the chai expect() to work with their framework.
Is there anything about Jasmine that you don't get out of the box with Cypress? I believe the expect() syntax may be different, if you have too many Jasmine-style expectations to change you may be able to add custom Chai expressions so that they work without modification.
I have a script that use Capybara to publish links in Google+. I would like to have tests to cover this functionality. Usually Capybara is using as a tool for writing Integration tests. In may case i need to test Capybara itself.
I see 3 possible ways:
stub capybara's method (but in this case i test nothing but just stubbed methods)
test capybara agains saved HTML/JS page (that will help me understand that i did not break anything during refactoring)
do not test at all (no comments here)
Have you ever faced such a problem?
If you register different drivers for your app and your test code, possibly manage the sessions manually depending on how you're using it in your app, and make sure you're careful with Capybaras setting's you should be able to go with option 2. You have to be careful with Capybaras settings because most of them are global so changing them for your tests will also change them for your app.
I am trying to debug in nightwatch.
When I put in a console.log it prints before the test runs - while its doing some sort of construction/compiling of the test.
I tried also visual studio code debugger and same thing - the breakpoint hits before the tests are actually run.
thanks for help - mark
"nightwatch" is built on node.js. Node.js executes statements asynchronously. If you write console.log();, it will be executed asynchronously.
The statements you write using browser (or client) object (e.g. browser.url(); , browser.click(); etc.) will be queued up at Selenium Server. They are also executed asynchronously by node.js but are queued up at selenium server.
To perform console.log() in sync with other statements in nightwatch, use .perform(). You will get output in sync with other statements.
Example
var elementValue;
browser
.getValue('.some-element', function(result) {
elementValue = result.value;
})
// other stuff going on ...
//
// self-completing callback
.perform(function() {
console.log('elementValue', elementValue);
// without any defined parameters, perform
// completes immediately (synchronously)
})
.end();
For debugging purpose, you can stop the execution to find out element values or check the browser related data. Use this command: browser.pause(); (or client.pause();). Do not pass any timer here. It will stop the execution.
As you don't really have an example, or some code that you run, i can only give you the general direction you can try in order to fix the issue.
This happens because your code is ran asynchronously (cause that's how javascript works) and everything that is not browser/html related will run before your browser starts your actual test. I suggest you should try using callbacks in order avoid printing your check msgs first (this way you link the console.log to your code that depends on the browser and it will run only after this finishes. If you do that, the debugging with console log will actually work.
Maybe you can learn here how to do that, as an example.
I'm familiar with python unittest tests where if an assertion fails, that test is marked as "failed" and it moves on to other tests. Jasmine on the other hand will continue through all expects even if the one of them fails. How can I make Jasmine stop processing a test after the first expectation fails?
it ("shouldn't need to test other expects if the first fails", function() {
expect(array.length).toBe(1);
// don't need to check this if the first failed.
expect(array[0]).toBe("foo");
});
Am I thinking about it wrong? I have some tests with lots of expect's and it seems like a waste to show all the stack traces when only the first is wrong really.
#Gregg's answer was correct for the latest version of Jasmine at that time (v2.0.0).
However, since then, this new feature was added in v2.3.0:
Allow user to stop a specs execution when an expectation fails (Fixes #577)
It's activated by adding throwFailures=true to the query string of the runner page, eg:
http://localhost:8000/?throwFailures=true
Jasmine doesn't support failing early, in a single spec. The idea is to give you all of the failures in case that helps figure out what is really wrong in your spec.
Jasmine has stop on failure feature and you can check it here:
https://plnkr.co/plunk/Ko5m6MQz9VUPMMrC
This starts jasmine with oneFailurePerSpec property.
According to the comments of https://github.com/jasmine/jasmine/issues/414 I figured out that 2 solutions exists for this:
https://github.com/radialanalytics/protractor-jasmine2-fail-whale
https://github.com/Updater/jasmine-fail-fast
I just started to use the protractor-jasmine2-fail-whale because it seems to have more features. Although to take screenshots in case of test failures I currently use protractor-jasmine2-html-reporter.
I'm using Jasmine in Appium (a tool to test React Native apps).
I fixed the issue by adding stopSpecOnExpectationFailure=true to Jasmine configs
jasmine v3.8.0 & jasmine-core v3.8.0