Typescript decorators for developing framework agnostic tests
MIT License
Typescript decorators for developing framework agnostic tests
To work with decorators you need to install the core package and a framework adapter package.
npm install @test-decorators/core
npm install @test-decorators/<framework-name>
First build your suite decorator, using SuiteDecoratorBuilder
import {SuiteDecoratorBuilder} from '@test-decorators/core';
import {JestSuiteFactory} from '@test-decorators/jest';
export const Suite = new SuiteDecoratorBuilder(
new JestSuiteFactory()
).build();
Then use it to build your test suites
@Suite()
class MyTestSuite {
testProp = false;
@BeforeEach() setup() {
this.testProp = true;
}
@It() 'should test'() {
expect(this.testProp).toBeTruthy();
}
}
The following adapters are available.
You can extend SuiteFactory to build your own adapters, and provide them to SuiteDecoratorBuilder
export class JestSuiteFactory extends SuiteFactory {
buildSuite(target: SuiteTarget): void {
const {suite} = target;
// build your suite with a framework
describe(suite.name, () =>; ...)
}
}
Any contribution following the above guidelines is really appreciated.
test-decorators is MIT licensed.