Skip to content

Introduction

Installation

To install, please execute the following command:

Terminal window
npm install kensajs --save-dev

Usage

Below is the simplest way to use it:

import Kensa from 'kensajs';
import { testFunction } from './testFunction';
const ks = Kensa();
ks.mainTitle('Test Title');
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.run();
  1. Import Kensa using import Kensa from ‘kensajs’;.
  2. Use test() to add tests.
  3. Execute the tests using run().
Execution Result
Terminal window
📄 Test Title
Test Item
TOTAL: 1, PASS: 1, FAIL: 0

Automation

By creating a .ks.js or .ks.ts file, you can automate the tests. Below is an example of automation:

  1. Add a script to package.json.
"test": "kensa"
  1. Create a .ks.js or .ks.ts file. If you are executing a .ks.ts file, please install ts-node.
Terminal window
npm install ts-node --save-dev

The creation method is as follows:

import Kensa from 'kensajs';
let ks = Kensa('Test Title');
ks.test({
title: 'Test Item',
input: testFunction(2, 4),
expect: 6,
});
ks.run();
  1. Import Kensa using import Kensa from ‘kensajs’;.
  2. Use test() to add tests.
  3. Execute the tests using run().
Test Execution
Terminal window
npm run test
Execution Result
Terminal window
📄 Test Title
Test Item
TOTAL: 1, PASS: 1, FAIL: 0