Light Weight Test Runner for Stackblitz

Scenario

We have a function sum(x:number, y:number) and we want to test it on Stackblitz.

Approach

Dependencies

We will use assert to verify test results.

Approach

Open a new Stackblitz Typescript project. Creates sum.ts and sum.spec.ts .

sum.ts

export function sum(x:number, y:number):number {
return x+y
}

sum.spec.ts

import { deepEqual } from 'assert'
import { sum } from './sum'
export function testSum() {
deepEqual(sum(1,1), 2, 'It should produce 2')
}

Import sum.spec.ts into index.ts and run testSum() .

Demo

Brought to You By Firefly Semantics

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ole Ersoy

Ole Ersoy

Founder of Firefly Semantics Corporation