0.0.47 โ€ข Published 5 months ago

codi-test-framework v0.0.47

Weekly downloads
-
License
MIT
Repository
-
Last release
5 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

5 months ago

1.0.37

5 months ago

1.0.36

5 months ago

1.0.35

5 months ago

1.0.34

5 months ago

1.0.26

5 months ago

1.0.25

5 months ago

1.0.29

5 months ago

1.0.28

5 months ago

1.0.27

5 months ago

1.0.32

5 months ago

1.0.31

5 months ago

1.0.30

5 months ago

1.0.22

6 months ago

1.0.24

6 months ago

1.0.23

6 months ago

1.0.19

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.21

6 months ago

1.0.20

6 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.11

7 months ago

1.0.12

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago

1.0.3

7 months ago

0.0.40

8 months ago

0.0.41

8 months ago

0.0.42

8 months ago

0.0.43

8 months ago

0.0.44

8 months ago

0.0.45

8 months ago

0.0.46

8 months ago

0.0.47

8 months ago

0.0.37

8 months ago

0.0.38

8 months ago

0.0.39

8 months ago

0.0.35

8 months ago

0.0.36

8 months ago

0.0.34

8 months ago

0.0.31

10 months ago

0.0.32

10 months ago

0.0.33

10 months ago

0.0.30

12 months ago

0.0.27

12 months ago

0.0.28

12 months ago

0.0.29

12 months 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