Chris Hager
Programming, Technology & More

Javascript

RSS Feed

How to test Vue.js plugins and extensions

This post shows how to write tests for Vue.js plugins and extensions by creating Vue.js instances, changing state and validating transformation and expected errors, to continuously verify that everything still works after updates, refactorings and merging contributions. While building python-boilerplate.com, I recently created a Vue.js plugin for syntax highlighting (vue-highlightjs), and wanted to add tests. For this I spent some time researching and testing how to properly test Vue.


Vue.js Syntax Highlighting with highlight.js

This post explains how to use highlight.js for syntax highlighting in a Vue.js application, allowing highlighting both on creation of an element as well as on updates to the source-code, using a simple v-highlightjs directive.
Everyone loves a good syntax highlighting. This post explains how to use highlight.js for syntax highlighting in a Vue.js application. The method shown here allows syntax highlighting both on original creation of an element as well as on updates to the source-code, using a simple v-highlightjs directive such as this: <pre v-highlightjs><code class="javascript"></code></pre> You can see a live example here: jsfiddle.net/metachris/1vz9oobc. To achieve this, we just need to install the highlight.


Custom Errors in TypeScript 2.1

TypeScript 2.1 introduced a number of breaking changes, among them that “Extending built-ins like Error, Array, and Map may no longer work”. For a subclass like the following: class FooError extends Error { constructor(m: string) { super(m); } sayHello() { return "hello " + this.message; } } methods may be undefined on objects returned by constructing these subclasses, so calling sayHello will result in an error. instanceof will be broken between instances of the subclass and their instances, so (new FooError()) instanceof FooError will return false.

swirl