BDD keywords on Mocha - mocha.js

What is the meaning of these keyword? I attempted to Google but havn't found anything.
describe() context() it() specify()
Mocha documentation

Related

Cypress with 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.

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?

is there an equivilent phpunit dataProvider functionality in ruby test-unit gem

I'm currently converting a whole bunch of acceptance tests from php into ruby and many of the tests use specific scenarios to test certain conditions. We use #dataProvider a lot and my google foo can't find any information if this functionality exists in the test-unit gem.
As a work around I'm manually calling a supporting method to give me the required values to test against and putting the test scenarios in var.each{} loops. It's not elegant but it works. I'd still prefer to use the dataProvider route if it's available though.
Your Google foo is probably very good, however in Ruby something similar is called a fixture.
Fixtures in Ruby Unit Tests

RSpec: Mocks, Stubs and Verification

I'm writing a plugin for Cinch (the IRC bot), and trying to write some RSpec tests for it.
However, I'm trying to get to grips with RSpec, and mocking out the external dependencies of this plugin. I want to test two different things for now - that it says hello to people, and that it keeps track of who it's said hello to.
So I've got a method, say_hello, which takes a Cinch::Message. What's the easiest way to mock this particular class? I'm used to Mockito and Java, so I'm used to making a mock of a particular class.
How can I make a mock of Cinch::Message? In my first test, I want to assert that the reply method is called on that message. In the next one, I just want it to respond like a Cinch::Message would, as I only care about the tracking the class does, not the interaction with the message.
I've only just started out with RSpec, so maybe I'm missing something fundamental. Should I be using a mock? A stub?
Thanks!
First of all documentation would be a nice start point, see: https://www.relishapp.com/rspec/rspec-mocks/v/2-11/docs/message-expectations
..and this is how your test could look:
it 'should call #reply on the message'
message = double('cinch message')
message.should_receive(:reply)
object_under_test.say_hello(message)
end

Executing JavaScript from a Cucumber/Capybara test

It appears that Selenium has a feature called JavascriptExecutor which makes it possible to execute JavaScript directly on the page. However it appears that there is no such thing available to my Cucumber/Capybara tests. How can I execute arbitrary JavaScript from my Cucumber tests?
Capybara has two methods to execute javascript #execute_script and #evaluate_script.
Both can be found at: http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Selenium/Driver
However, do note that the readme has this statement about the above methods:
For simple expressions, you can return the result of the script. Note
that this may break with more complicated expressions:
See http://rubydoc.info/github/jnicklas/capybara/master/file/README.md.

Resources