RxJS Marble testing: expectObservable vs toBeObservable - unit-testing

What is the difference between:
expectObservable(e1.merge(e2)).toBe(expected);
and
expect(e1.merge(e2)).toBeObservable(expected);
syntax?
Is it matter of a testing library or just a flavor?

Based on my usage:
toBeObservable is from third party library, jasmine-marbles
expectObservable is from build in rxjs module: TestScheduler.

Seems like the official repos use a .toBeObservable matcher.
https://github.com/synapse-wireless-labs/jasmine-marbles/blob/master/spec/integration.spec.ts
https://github.com/cartant/rxjs-marbles
Not sure why the RxJS documentation uses expectObservable()

Related

Has DAOTestRule been deprecated from Dropwizard? What is the alternative?

I am using Dropwizard and I want to unit test my DAO classes. I saw a bunch of examples online but they seem to be using DAOTestRule which I cannot find in 0.9.2 which is what we use here at work.
None of the blogs explain what is the replacement or why it was deprecated in the first place. The official documentation doesn't detail anything either. How can I go about testing my DAO and setting up an in-memory database for Dropwizard Testing?
See issue Can't find DAOTestRule.java at dropwizard-testing maven 1.0.5 version jar.
Answer
That's because it's only available in Dropwizard 1.1.x and later.
https://github.com/dropwizard/dropwizard/commits/master/dropwizard-testing/src/main/java/io/dropwizard/testing/junit/DAOTestRule.java
See also this issue. Looks like it was also back-ported to 1.0.6.
What is the alternative?
Update your DW version.

What will be a good way to test non react components used in ReactJS?

What will be a good way to test non react components in ReactJS. We currently use Enzymes but that is limited to react components. What will be a good way to unit test non react components.
From Enzyme's Github page:
"Enzyme is unopinionated regarding which test runner or assertion library you use, and should be compatible with all major test runners and assertion libraries out there. The documentation and examples for enzyme use mocha and chai, but you should be able to extrapolate to your framework of choice."
Pretty sure you can test any sort of javascript with Enzyme, just don't use the constructs built into Enzyme that were made for Enzyme, or even better use assertion libraries that you need for your non-react components.
EDIT: Some caveats you might run into, but there are solutions for them https://github.com/airbnb/enzyme/issues/278
Test as you would normally do. Enzyme does not have a test runner or assertion framework. If you are using Mocha and Chai, then write tests with Mocha and Chai as you would normally do.

Using Spock, how do you run a particular feature via the grails command line?

I am running Spock tests for unit and functional tests. Awesome library.
I am wondering how to run a specific feature of a Spock Spec from the grails command line.
I know how to run all spock tests or run a specific spec but I don't know how to run a specific feature.
Thanks!
As Peter Niederwieser mentionned in his comment, this isn't possible with Spock. However, the annotation #IgnoreRest will serve the same purpose. Marking the question answered. Thank you

What autotest tools exist for Clojure

I was wondering what autotest tools exists for clojure. In Ruby I have ZenTest, redgreeen etc to continuously keep on testing my code. I would like to have something similar for Clojure
So far I have found this simple script https://github.com/devn/clojure-autotest on the github. A bit crude for my taste. All tests run when a change occurrs. Also it may blurt out a long stacktrace in case of syntax errors, obscuring what goes wrong.
Take a look at the Testing section on the Leiningen plugin page.
Notably there's lein-autotest for Stuart Sierras lazytest framework and speclj.
If you are using clojure.test there are a few options available. lein-test-refresh is what I use (I'm also the author). Other options include quickie and prism.
If you use expectations then there is lein-autoexpect. I'm also the author of that.
Midje has built in support for autotesting. I'm not sure what the options are for Speclj.

Unit testing Scala

I just recently started learning the Scala language and would like to do it in TDD-way. Could you share your experiences on the unit testing frameworks there are for Scala and the pros/cons of them.
I'm using IntelliJ IDEA for Scala development, so it would be nice to be able to run the tests with IDE-support.
Have you looked at ScalaTest ?
I've not used it, but it comes from Bill Venners and co at Artima, and consequently I suspect it'll do the job. It doesn't appear to have IDE integration, however.
This blog entry is a little old, but suggests that TestNG is the best option for testing Scala. TestNG will certainly have IDE integrations.
EDIT: I've just realised that I wrote this answer in 2009, and the world has moved on (!). I am currently using ScalaTest, the IDE integration works fine, and I can strongly recommend it. In particular the matcher DSL works very nicely
I'm the author of specs. If you're a Intellij user, I advise you to mix-in in the org.specs.runner.ScalaTest trait to your specification and run it as a ScalaTest suite.
If you have any issue with that, or anything else feel free to send a message to the specs-users mailing list.
You could also check out Specs it's fairly complete and IIRC is heavily used as part of Lift.