Calling a function in a child or sibling component in React

“How to call a function in child or sibling component” is a fairly frequently asked question in React world. This is how we’ve solved it.

The setup is this: we have a parent component and one or two child components. We need to raise an event in a child component either from the parent component, or we need a child component A to raise an event in child component B.

Continue reading “Calling a function in a child or sibling component in React”

Visual Studio remote debugging over HTTPS

Quick hint: to enable IIS Express in VS to work with HTTPS, change “SSL Enabled” to true in project properties, and change project URL in Web tab to something like “https://localhost:44300”. The port MUST be 44300 or higher.
Props

props2

No more “This site can’t be reached

The connection was reset.
Try:
Checking the connection
Checking the proxy and the firewall

A good read: Working with SSL at Development Time is easier with IISExpress

How to run Jasmine tests as nUnit tests and test sites you don’t own.

Problem:
We’ve been using a 3rd party tool to generate a page, and I had to test some data there.
Since I had no knowledge of the DOM (it would be preferable to think of it as a black box), I couldn’t really use traditional tools that would validate the presence of certain elements on a page. A better way would be to inject a script into a page and validate the content of some global variables.

In my scenario it also would be preferable to keep test code separate from the site being tested and treat it as something I don’t own (it’s being built by another team, so it would be easier).

So I want to be able to inject my Jasmine tests into a page; I want to see the list of tests as NUnit tests. Continue reading “How to run Jasmine tests as nUnit tests and test sites you don’t own.”

Controller communication in AngularJS

Quite often there is a need to pass data from one controller to another. This is relatively easy if we need to pass data from child to parent controller, but not so straight forward when controllers are not in that relationship.
Still, there’s quite a few ways of achieving that, differing in ease of implementation (though none are hard), performance and ease of maintenance.

Angular offers emit/broadcast/on methods on a scope, which are a lot like events in say C#, but they only broadcasted up and down in scope inheritance, so if you need to share data with sibling or some random controller in your app you need to jump through the hoops. Continue reading “Controller communication in AngularJS”

Data mocking in angular E2E testing

We needed to create a suite of e2e tests for our web app, preferably without having to hit the database for obvious reasons.
So basically I wanted to have a solution that satisfies these requirements:

  • Allows easy switch between real and test data, for example by specifying a URL parameter.
  • Allow specifying a mock data source, and a way to manipulate that mock data after it was loaded from the source.

Angular has a fake $httpBackend implementation designed specifically for providing a mock data response when you’re using $http service. Continue reading “Data mocking in angular E2E testing”