@yumii.saiko/testy
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

Testy 🧨

Utilizing your typical framework, write your test using Typescript decorators.

Test on npm  

What 👽 ? (it is what it is ... and what it isn't...)

It

  • Allows you to write your test with Typescript decorator while using your favorite testing framework
  • ... is a candy for the Java JUnit folks

It isn't

  • a framework, which does nothing for you but convert your functionally rich file into a more modular format

Features ✨

  • [x] Modular test
  • [ ] Decorators
    • [x] Test Class: @TestClass(desc?)
    • [x] Hooks: @BeforeAll, @BeforeEach, @AfterEach, @AfterAll
    • [ ] Test Suites: @Test(desc?, skip?, order?)
      • [x] Base decorator
      • [x] skip
      • [ ] Order (not really useful)
  • [ ] Testing Platform impl
    • [x] Custom platform
    • [x] jest
    • [ ] vitest
    • [ ] Mocha
    • [ ] playwright
    • [ ] cypress
    • [ ] Jasmine

Usage

The folowing example uses the Jest testing platform

Suppose you have a _function sum(...numbers)_ function in a file named `sum.ts`. You would like it to contain both the `sum` function and its `test`. Here's how you could accomplish that.

src/sum.ts

import {TestClass, Test} from "@yumii.saiko/testy";

export function sum(...numbers: number[]) {
  return numbers.reduce((acc, n) => acc + n, 0);
}

@TestClass({
  desc: "fn Sum()",
})
export class SumTest {
  @Test()
  should_compute_numbers_sum() {
    expect(sum(10, 10)).toEqual(20);
  }

  @Test({
    skip: true,
    desc: "Explicitly skip this for now",
  })
  not_implemented_yet() {}
}

Using the filename pattern that your testing framework might identify, example src/test/*/**/*.spec.ts, create a single file in which all of the Test class registrations should go.

src/test/bootstrap_test.spec.ts

import {defineTests} from "@yumii.saiko/testy";
// There we provided our own impl for jest platform
// Testy will come with a set of platform so you don't need to impl them yourself
import {PlatformJestImpl} from "../lib/testy_platform_jest";
import {SumTest} from "../sum";

defineTests([SumTest], PlatformJestImpl);

Run

npm test

screenshot (jest)

jest_testy

You can find the code for this example in the example folder

Package Sidebar

Install

npm i @yumii.saiko/testy

Weekly Downloads

1

Version

0.4.1

License

MIT

Unpacked Size

23.9 kB

Total Files

52

Last publish

Collaborators

  • yumii.saiko