Language
Quick Links
What is ESCSS-ESTest?
ESCSS-ESTest helps you to achieve 100% coverage by taking the potential of TDD and TypeScript.
Core Concept - Water Filter
function foo() {
{
}
}
Usage
Use Cases
ESTest(NaN, "NaN");
ESTest([], "array");
ESTest(null, "null");
ESTest(undefined, "undefined");
ESTest(1, "number");
ESTest("foo", "string");
ESTest(true, "boolean");
ESTest({}, "object");
ESTest(1n, "bigint");
ESTest(Symbol(), "symbol");
ESTest(function () {}, "function");
ESTest(1, "object");
ESTest(1, "object", "foo");
Pure vs Impure
import { ESTest } from "escss-estest";
let isEnable = true;
function pureSum(a, b) {
{
ESTest(a, "number");
ESTest(b, "number");
ESTest(isEnable, "boolean");
}
if (!isEnable) return 0;
return a + b;
}
function impureSum(a, b) {
if (!isEnable) return 0;
return a + b;
}
function total(x) {
{
ESTest(x, "number");
ESTest(pureSum, "function");
}
return x + pureSum(1, 2);
}
Error handling: async/await
import { ESTest } from "escss-estest";
async function getData() {
const url = "https://jsonplaceholder.typicode.com/todos/99999";
const response = await fetch(url);
const json = await response.json();
{
ESTest(json, 'object')
ESTest(json.userId, "number");
ESTest(json.id, "number");
ESTest(json.title, "string");
ESTest(json.completed, "boolean");
}
console.log(json);
}
getData();
Error handling: class
import { ESTest } from "escss-estest";
class Animal {
constructor(name, age) {
{
ESTest(name, "string");
ESTest(age, "number");
}
this.name = name;
this.age = age;
}
}
new Animal("cat", "10");
Installation
npm add escss-estest
yarn add escss-estest
pnpm add escss-estest
bun add escss-estest
npx nuxi module add nuxt-escss-estest
License
see