yajstf

1.0.3 • Public • Published

Yet Another JavaScript Testing Framework

npm version

Description

yajstf is a very lightweight testing framework that is incredibly fast to get started with.

If you are curious about how to write a testing framework, take a peek into the code and if you want to borrow any source code just take a look at the terms and conditions in the License.

Getting Started

Installing yajstf

Install yajstf using npm:

npm install --save-dev yajstf

Or yarn:

yarn add --dev yajstf

Writing your first test

Let's get started by writing a test for a hypothetical function that adds two numbers. First, create a sum.js file:

function sum(a, b) {
  return a + b;
}
module.exports = sum;

Then, create a file named sum.test.js. This will contain our actual test:

const assert = require('assert');
const { sum } = require('../index');


test('adds 1 + 2 to equal 3', () => {
  assert.strictEqual(sum(1, 2), 3);
});

Add the following section to your package.json:

{
  "scripts": {
    "test": "jtf"
  }
}

Finally, run npm run test or yarn test and yajstf will print this message:

✓  TEST - adds 1 + 2 to equal 3 - PASSED

You just successfully wrote your first test using yajstf!

This test used assert and strictEqual to test that two values were exactly identical.

Running from command line

You can run yajstf directly from the CLI (if it's globally available in your PATH, e.g. by npm install yajstf --global) or yarn global add yajstf.

License

yajstf is WTFPL licensed.

Package Sidebar

Install

npm i yajstf

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

8.13 kB

Total Files

12

Last publish

Collaborators

  • christopher.harold.butler