@yumii.saiko/testy
v0.4.1
Published
Decorator-based testing framework that abstracts existing testing framework
Downloads
11
Maintainers
Readme
- Allows you to write your test with Typescript decorator while using your favorite testing framework
- ... is a candy for the Java JUnit folks
- a framework, which does nothing for you but convert your functionally rich file into a more modular format
- [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
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)