Cypress with Jasmine - jasmine

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.

Related

CSSTransition component's callbacks are not called in Cypress testing environment

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()
})

How to use e2e or unit testing with nativescript-vue?

How to use e2e or unit testing with nativescript-vue?
Would you please describe a Getting Started kind of guide?
Is there any tested testing method with nativescript 7 ?
Does appium or detox really work?
Is it possible to update ui-tested-nsvue-app somehow?
Here for unit testing, How to set up unit testing in NativeScript Vue
Foe e2e take a look on this, NativeScript-Vue UI tests
Didn't try this repository yet but considering who the contributors are it seems promising.

Do not report skipped tests with karma-jasmine-html-reporter

Is there a way to prevent karma-jasmine-html-reporter aka kjhtml from reporting skipped/pending tests?
I run some tests using fit and fdescribe and I want to only see results for the selected tests, however, the reporter is always displaying all tests from the suite.
Apparently, yes, there's a way to that with Jasmine (starting from v3.3.0). I've been able to do that in an Angular project. In the test.ts I've put something like:
jasmine.getEnv().configure({ hideDisabled: true });
Official documentation here: https://jasmine.github.io/api/3.5/Configuration.html.

Using Mocha features in Karma?

I'm unit testing my Javascript (AngularJS) app using Karma, Mocha and Chai. This all works fine, however in Mocha's doc I see a lot of cool stuff like custom reporters and text diffs on failures. How can I use these features when not using Mocha directly but trough karma-mocha?
As an example, how could I use Mocha's "Landing Strip" reporter instead of Karma's default "dots" or "progress" reporters?

Stop jasmine test after first expect fails

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

Resources