Skip to content

ChristopherHButler/yajstf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Yet Another JavaScript Testing Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published