Skip to main content

Posts

Angular - Karma–Chromeless tests fail with ERROR - Disconnected, because no message in 10000 ms.

After switching from PhantomJs to Chrome in headless mode for our Angular tests, our tests started to behave flaky with sometimes success and sometimes failure. When the tests failed, we saw the following error message in the logs: [32m28 08 2018 10:41:44.851:INFO [HeadlessChrome 68.0.3440 (Windows 7.0.0)]: [39mConnected on socket W4CI4bKonF845CKZAAAA with id 22875346 2018-08-28T08:41:54.8669569Z [33m28 08 2018 10:41:54.860:WARN [HeadlessChrome 68.0.3440 (Windows 7.0.0)]: [39mDisconnected (1 times), because no message in 10000 ms. 2018-08-28T08:41:54.8864889Z HeadlessChrome 68.0.3440 (Windows 7.0.0) ERROR 2018-08-28T08:41:54.8864889Z   Disconnected, because no message in 10000 ms. 2018-08-28T08:41:54.8874655Z HeadlessChrome 68.0.3440 (Windows 7.0.0) ERROR 2018-08-28T08:41:54.8874655Z   Disconnected, because no message in 10000 ms. 2018-08-28T08:41:54.8874655Z To fix it, we changed the default Karma settings to a more fault tolerant con...

FluentValidation MustAsync causes API timeout

One of the developers in my team complained that one of the ASP.NET Web API requests was really slow and asked me to investigate the performance issue. When I opened the solution I saw the following code: Do you notice what’s wrong? The problem is that inside the validator an async call is done where if you look at the controller the validator is invoked in a synchronous way. This causes the API to hang as ASP.NET keeps waiting for a result that is never returned. The solution was simple; just switch to the ValidateAsync method and await the result in the controller:

Running chrome in headless mode for Angular E2E tests

If you used the Angular CLI to create your Angular project, there is not that much work left to do to start using Chrome in headless mode to run your end-to-end tests. Let’s walk through the steps: Open the protractor.conf.js file in the e2e folder. Change the capabilities entry in the config to include a chromeOptions object like this: capabilities: {   chromeOptions: {     args: [ "--headless" ]   },   'browserName': 'chrome' }, By using the args property, we pas a --headless option. This configures Chrome to run in headless mode. That is all we need to do . Just kick off your E2E tests using: npm run e2e

ASP.NET Core–Swagger error when using a virtual directory

After changing our ASP.NET Core application to no longer run under the root site(e.g. https://localhost/ ) but under a virtual directory instead (e.g. https://localhost/mysampleapp/ ) , loading the API definitions in Swagger no longer worked and failed with the following error message: Fetch error undefined swagger/v1/swagger.json To fix the problem, I had to do 2 things: First I updated the Swagger json generation to set the SwaggerDoc to a specific path. Although the documentation mentions the first parameter of SwaggerDoc as the name, it becomes part of the URI of your swagger.json file. In this case I set the name to ‘v1’: As a second step, I had to update the Swagger UI configuration to generate the swagger endpoint on a relative path. Important here is that the name of the swagger doc matches part of the URI before the swagger.json; in our case ../swagger/ v1 /swagger.json

Ionic Menu control won’t refresh

Last week we lost a lot of time investigating an issue with ‘ion-menu’ , one of the built-in controls of Ionic. The problem was that once the menu was opened it would no longer refresh it’s data. What we do is showing some user data on the top of the menu, this data is returned with an http call from the server and updated through an observable subscription. However pushing a new value on the observable had no effect on the view although the component data was in fact updated. As a workaround we used the built-in event bus to publish an event once the user was loaded. We handle this event on the viewcomponent and use it to explictly trigger a change detection: More information about the ChangeDetectorRef can be found here: https://alligator.io/angular/change-detection-strategy/

Discover the world of .NET with .NET Conf

The next edition of .NET Conf is getting closer. From September 12 until September 14, you can learn about the latest and greatest in the .NET ecosystem. From the .NET Conf site : .NET Conf is a FREE, 3 day virtual developer event co-organized by the .NET community and Microsoft. Over the course of the three days you have a wide selection of live sessions streaming here that feature speakers from the community and .NET product teams. It's a chance to learn, ask questions live, and get inspired for your next software project. You will learn to build for web, mobile, desktop, games, services, libraries and more for a variety of platforms and devices all with .NET. We have sessions for everyone, no matter if you are just beginning or are a seasoned engineer. We’ll have presentations on .NET Core and ASP.NET Core, C#, F#, Azure, Visual Studio, Xamarin, and much more.

Angular Console–Angular CLI made easy

The guys from Nrwl are introducing the Angular Console; a more approachable way to work with all the features that the Angular CLI already provides. The Angular Console is available at https://angularconsole.com/ and offers the following set of features: Trivial Code Generation: Leverage the CLI's built in generators for Components, Providers and more, all without having to remember a single command line flag. Run Custom NPM Scripts: As well as the standard `ng` commands, all of your custom npm scripts are automatically detected and allow you to run them with a single click. Discover and Install Extensions: Search through a comprehensive list of official and community schematics to extend the power of the Angular CLI even further, and install them directly in the UI. Build CLI Commands Visually: Using a visual form-driven UI, you get all of the flags and arguments for your chosen command available inline. Integrated Terminal Output: As you compose and ...