an open source decorator based testing framework for typescript
- decorator based testing
- watch mode
- async tests with not efforts
currently this repo is not released yet so you have to fork and clone the repo before using it.
run npm install
run cd examples && npm install
run oral
writing tests in oral is same as writing tests in other framework but in oral, there is no describe and no it, instead of that, it usesname of you class as description of you tests. To get started with it
touch oral.config.ts && mkdir tests
- oral.config.ts
module.export = {
testDir: "/tests",
};
cd tests && touch firstTest.test.ts
inside firstTest.test.ts
import { Suit, Equal } from "oral";
@Suite()
export class myFirstTest {
@Equal("this should pass")
thisShouldPass() {
return "this should pass";
}
@Equal(5)
thisShouldFail() {
return 2 + 2;
}
}
save and run
oral --watch
and here you go..
oral location of config file
--watch
--testDir /tests/
--clear
--noclear
--help
--version
--notify
--file name_of_file
all cli options can be inclue in oral.config.ts
@Equal()
@Suite()
@Contain()
@Match()
@True()
@False()
@GreaterThan()
@LessThan()
@Instanceof()
@Typeof()
@Extend()
@Before()
@After()
@Util()
@BeforeEach()
@AfterEach()
more coming soon.
detailed examples in example/tests folder...
continue reading to know more...
import { Suite, Before, After, Equal } from "oral";
@Suite()
export class beforeAfterTest {
name: string;
@Before()
before() {
this.name = "a name";
// create connection
}
@Equal("a name")
shouldReturnName() {
return this.name;
}
@After()
after() {
this.name = undefied;
// drop database
}
}
import { Util, Suit, GreaterThan } from "oral";
@Suite()
export class utilTest {
@Util()
@GreaterThan(5)
aUtil(num1: number, num2: number) {
return num1 + num2;
}
realTest() {
this.aUtil();
}
}
do not support in new version currenly, available soon !!! git checkout old
to use this
oral.config.ts
function Afunc() {
// create database
return "a global string";
}
module.export = {
beforeEveryone: Afunc,
};
- aTest.test.ts
import { Suite, Equal } from "oral";
@Suite()
export class aTest {
str: string;
constructure(str: string) {
this.str = str; // aFunc's returned value
}
@Equal()
checkIfStrExist() {
return this.str;
}
}
import { Extend, Suite } from "oral";
const decoratorFunc = (val: string) => {
if (val === "a string") return true;
return false;
};
@Suite()
export class extendDecoratorTest {
@Extend("my own decorator", decoratorFunc)
extendDecoratorTesting() {
return "a string";
}
@Extend("my own decorator", decoratorFunc)
extendDecoratorTestingFail() {
return "a false string";
}
}
import { Suite, Equal, BeforeEach, AfterEach } from "oral";
@Suite()
export class beforeEveryone {
num = 0;
@BeforeEach()
beforeEach() {
this.num = this.num + 1;
}
@AfterEach()
beforeEach() {
this.num = 0;
}
@Equal(1)
checkIfEqualOne() {
return this.num;
}
@Equal(1)
checkIfEqualOneAgain() {
return this.num;
}
}
Hello i am tanay pingalkar. I like to code things that helps other and are open and free. I have created this testing framework for using the power of decorators and to give testers a complete new exciting workflow. This framework is typescript specific and dedicated to it. This framework believe that every assertion counts the quality of software and thats why every method in a class is a assertion. I currently dont have a good name but I call it "oral" (@ral) for some reason. Suggestion for name is needed. This project is open source and Licensed under MIT License. I will like to see feedback and ideas on github issues to make it better.
this porject is open source and will always live open source. Contributer's are highly welcome and appreciated. You can read CONTRIBUTING.md and CODE_OF_CONDUCT.md to know more about contribution process.