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()
.