JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q67098F
  • License MIT

Decorator-based testing framework that abstracts existing testing framework

Package Exports

  • @yumii.saiko/testy
  • @yumii.saiko/testy/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@yumii.saiko/testy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 ✨

  • Modular test
  • Decorators
    • Test Class: @TestClass(desc?)
    • Hooks: @BeforeAll, @BeforeEach, @AfterEach, @AfterAll
    • Test Suites: @Test(desc?, skip?, order?)
      • Base decorator
      • skip
      • Order (not really useful)
  • Testing Platform impl
    • Custom platform
    • 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