npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

codi-test-framework

v0.0.26

Published

A simple test framework for JavaScript

Downloads

703

Readme

Codi Test Framework 🐶

License example workflow

Codi is a lightweight JavaScript test framework that allows you to write and run tests for your JavaScript code. It provides a simple and intuitive API for defining test suites and test cases, making it easy to ensure the correctness of your code. ✨

Features ✅

  • 📝 Simple and expressive API for writing tests
  • 🏗️ Supports test suites and test cases
  • 🔍 Provides assertion functions for comparing expected and actual values
  • 🌈 Colorful output for better readability
  • 🖥️ Supports running tests from the command line
  • 🌐 Compatible with ECMAScript modules (ESM)
  • ⚡ Super fast thanks to bun.sh

Installation 📦

To use Codi in your project, you need to have Node.js installed. You can install Codi as a development dependency using npm:

npm install --save-dev codi-test-framework

For user using codi v0.0.14^ ensure that you have bun v1.1.0 installed.

Usage 🛠️

Writing Tests ✍️

To write tests using Codi, create a new test file with a .mjs extension. Use the describe function to define a test suite and the it function to define individual test cases.

Here's an example test file:

import { describe, it, assertEqual } from 'codi-test-framework';

describe('Math operations', () => {
  it('should add two numbers correctly', () => {
    const result = 2 + 3;
    assertEqual(result, 5, 'Addition should work correctly');
  });

  it('should subtract two numbers correctly', () => {
    const result = 5 - 3;
    assertEqual(result, 2, 'Subtraction should work correctly');
  });
});

Assertion Functions 🧪

Codi provides several assertion functions to compare expected and actual values:

  • assertEqual(actual, expected, message): Asserts that the actual value is equal to the expected value. ⚖️
  • assertNotEqual(actual, expected, message): Asserts that the actual value is not equal to the expected value. 🙅‍♂️
  • assertTrue(actual, message): Asserts that the actual value is true. ✅
  • assertFalse(actual, message): Asserts that the actual value is false. ❌
  • assertThrows(callback, errorMessage, message): Asserts that the provided callback function throws an error with the specified error message. 💥

Running Tests 🏃‍♂️

To run the tests, use the runTests function and provide the directory containing your test files:

import { runTests } from 'codi-test-framework';

runTests('./tests');

You can also run the tests from the command line using the runCLI function:

codi ./tests

License 📄

This project is licensed under the MIT License.


Feel free to contribute to Codi by opening issues or submitting pull requests. Happy testing! 😄