Testing asynchronous function with mocha

You have to specify the callback done as the argument to the function which is provided to mocha – in this case the it() function. Like so: describe(‘api’, function() { it(‘should load a user’, function(done) { // added “done” as parameter assert.doesNotThrow(function() { doRequest(options, function(res) { assert.equal(res, ‘{Object … }’); // will not fail assert.doesNotThrow … Read more

When should I use Debug.Assert()?

In Debugging Microsoft .NET 2.0 Applications John Robbins has a big section on assertions. His main points are: Assert liberally. You can never have too many assertions. Assertions don’t replace exceptions. Exceptions cover the things your code demands; assertions cover the things it assumes. A well-written assertion can tell you not just what happened and … Read more

Protractor: Scroll down

You need to wait for the promise to be solved. The following example comes from an open issue browser.executeScript(‘window.scrollTo(0,0);’).then(function () { page.saveButton.click(); }) Update: This is an old question (May of 2014), but still it is getting some visitors. To clarify: window.scrollTo(0, 0) scrolls to the top left corner of the current page. If you … Read more

Mocking USB input

Mocking usb devices using umockdev Umockdev is a linux based application which record the behaviour as well as properties of hardware and run the software independent of actual hardware it is running on. Hardware devices can be simulated in virtual environments without disturbing the whole system.It currently supports sysfs, uevents, basic support for /dev devices, … Read more

com.android.builder.testing.ConnectedDevice > hasTests[test(AVD) – 5.0] FAILED

Updated response: VM images already include fixed android-wait-for-emulator script and android SDK tools version 24.0.0 by default solving other issues. Build Environment Updates – 2014-12-09 Brief response: Bugged script causes your emulator don’t be ready for your tests and your app is not installed due a timeout, so there are no tests performed and the … Read more