Skip to content

Content Tagged "typescript"

Page 1 of 1

Content Tagged "typescript"

Use Shared Variables with Cypress in Typescript

September 11, 2019Categories: Software, Tutorial
This week I started adding Cypress testing to my blog (with some surprises too!). I insisted to use typescript with Cypress and my code looks now like this: This is fine and it works. Thing is that I have the text 'Laur IVAN|PRO" defined in another file and the site is getting it from that file…

Fix TS1144 for e.g. flex-layout

September 5, 2018Category: Software
TL;DR: Update your typescript version dependency. These days we're updating some angular apps to the most recent version (6 at the time of writing this entry). Everything is nice, with the exception of various errors we get because of the other dependencies. The most recent one was a TS114…

Change the File Extension in Typescript (or Javascript)

April 18, 2017Categories: Software, Tutorial
TL;DR: You need to get the root name (without the extension) and append the new extension. Then, it only depends on how tolerant you are. The other day I figured I needed a function to change the file extension (from a .jpg to a .nfo ). Since I haven't found a ready made function to do this, I…

Consistent Testing electron-settings

April 6, 2017Categories: Software, Tutorial
TL;DR : Delete the settings file before starting the test. Today I implemented a simple wrapper over the electron-settings functionality to gibe me access to a set of properties via get/set methods. My scenario is simple: I have a property named path.backup and I want to be able to get , set…

Poor Man's Mocks in TypeScript

March 7, 2017Categories: Software, Tutorial
Today I went against my better judgement of usign a mock framework and decided to create my own mocks to allow coverage testing for an IPC-calling code. My reference code I wanted to test is: The code would use an angular service named PathService which, for the purpose of this test only has a…

Use "toThrowError" and "toThrow" in TypeScript with Objects

March 2, 2017Category: Software
TL;DR: wrap your method call in the expect() statement. Instead of expect(obj.method()).toThrow() , write expect( () => { obj.method() }).toThrow() . While in the process of improving the code coverage, I needed to write a test for a method throwing an exception. My initial code would have been…

Initialize a Typescript Interface with JSON

February 20, 2017Category: Software
TL;DR: You can initialise a typescript interface using JSON objects. On my quest to load and save objects as JSON, I found that you can convert a JSON object to an interface via something called type assertion . Basically, if you have an interface: you can load a JSON object via JSON.parse(json…

Check Duplicated Paths with LoDash (and Angular 2)

February 20, 2017
One of the things I'm looking at is to be able to create a list of paths I'd want to scan. The first iteration had blind addition to the list. However, this would make the user's responsibility to manage the duplicated paths, which is not really nice. Therefore, I think it's a good thing to add some…

Angular 2Refresh Bound Variables from Callback

January 31, 2017Category: Software
TL;DR: Use ChangeDetectorRef 's detectChanges() at the end of your callback code. While developing my electron.js app, I've had the following workflow: I have an input element and a button The input element is capable of editing a path The button triggers a File Open dialog The…

Scan Decorated Classes in Typescript

December 21, 2016Categories: Software, Tutorial
TL;DR: Make the decorator set a property in the class and look for it. While trying my hand at writing an ORM, I had a problem of initialising the database through a dummy instantiation of some models, without running an explicit command. In java, I can use code generation to provide a list of…

All tags