0.0.47 โ€ข Published 6 months ago

codi-test-framework v0.0.47

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

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! ๐Ÿ˜„

1.0.33

6 months ago

1.0.37

6 months ago

1.0.36

6 months ago

1.0.35

6 months ago

1.0.34

6 months ago

1.0.26

6 months ago

1.0.25

6 months ago

1.0.29

6 months ago

1.0.28

6 months ago

1.0.27

6 months ago

1.0.32

6 months ago

1.0.31

6 months ago

1.0.30

6 months ago

1.0.22

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.21

7 months ago

1.0.20

7 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.11

8 months ago

1.0.12

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

1.0.3

8 months ago

0.0.40

9 months ago

0.0.41

9 months ago

0.0.42

9 months ago

0.0.43

9 months ago

0.0.44

9 months ago

0.0.45

9 months ago

0.0.46

9 months ago

0.0.47

9 months ago

0.0.37

9 months ago

0.0.38

9 months ago

0.0.39

9 months ago

0.0.35

9 months ago

0.0.36

9 months ago

0.0.34

9 months ago

0.0.31

11 months ago

0.0.32

11 months ago

0.0.33

11 months ago

0.0.30

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.26

1 year ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.15

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago