Skip to content

Title

Main Title

Set the test’s main title with ks.mainTitle('Main Title Name').

import Kensa from 'kensajs';
import { testFunction } from './testFunction';
const ks = Kensa();
ks.mainTitle('Main Title');
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.run();
Execution Result
Terminal window
📄 Main Title
Test Item
TOTAL: 1, PASS: 1, FAIL: 0

Subtitle

Set the test’s subtitle with ks.subTitle('Subtitle Name'). Subtitles are automatically numbered.

import Kensa from 'kensajs';
import { testFunction } from './testFunction';
const ks = Kensa();
ks.mainTitle('Main Title');
ks.subTitle('Subtitle');
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.subTitle('Subtitle');
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.run();
実行結果
Terminal window
📄 Main Title
1. Subtitle
Test Item
2. Subtitle
Test Item
TOTAL: 2, PASS: 2, FAIL: 0

You can set the level of the subtitle with ks.subTitle('Subtitle Name', level).

import Kensa from 'kensajs';
import { testFunction } from './testFunction';
const ks = Kensa();
ks.mainTitle('Main Title');
ks.subTitle('Subtitle');
ks.subTitle('Subtitle', 2);
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.subTitle('Subtitle', 2);
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.subTitle('Subtitle');
ks.subTitle('Subtitle', 2);
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.subTitle('Subtitle', 2);
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.test({
title: 'Test Item',
input: testFunction(1, 1),
expect: 2,
});
ks.run();
実行結果
Terminal window
📄 Main Title
1. Subtitle
1. Subtitle
Test Item
Test Item
2. Subtitle
Test Item
Test Item
2. Subtitle
1. Subtitle
Test Item
Test Item
2. Subtitle
Test Item
Test Item
TOTAL: 8, PASS: 8, FAIL: 0