Preslav's Thoughts and Ramblings

javascript

  • 06 May 2017

    Testing React Native Applications Part I: Jest

    When I started with React Native not long ago I was frustrated by the overwhelming amount of irrelevant information on how to test React applications. React is known to evolve fast, often introducing breaking changes, so this should not be surprising to most developers. Still, the amount of deprecated content...

  • 26 February 2017

    Dealing with Python-Version Exceptions When Using node-gyp

    I was trying to install a JavaScript library called numjs (basically, a JS equivalent to numpy), when I got the following exception: # Executing the following command... $ npm install numjs --save # resulted in ... gyp ERR! UNCAUGHT EXCEPTION gyp ERR! stack Error: spawn EACCES gyp ERR! stack at exports._errnoException (util.js:...

  • 01 May 2016

    FIX: Angular2 - Missing Http Observable.map Function

    The first Http example that most new Angular 2 users get to try their hands on, is this code snippet taken from the Angular 2 Http Docs: import {Http, HTTP_PROVIDERS} from 'angular2/http'; @Component({ selector: 'http-app', viewProviders: [HTTP_PROVIDERS], templateUrl: 'people.html' }) class PeopleComponent { constructor(http: Http) { http.get(...

  • 23 January 2016

    Injecting Services in Angular 2 and Ionic 2

    Create a service: import {Injectable} from 'angular2/core'; @Injectable() export class MyService { constructor(http: Http) { // initalize things } doSomething() { // do something } } Injecting the newly created service per component In vanilla Angular 2.0, as well as in Ionic 2 applications, you need to import the service class and add it to...

  • 22 August 2015

    ngMock Helpers

    Let’s take a controller test straight out of the Angular JS Docs: describe('PasswordController', function() { beforeEach(module('app')); var $controller; beforeEach(inject(function(_$controller_){ // The injector unwraps the underscores (_) from around the parameter names when matching $controller = _$controller_; })); describe('$scope.grade', function() { it('sets the strength to "strong"...