Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaosdev/test-decorators
Typescript decorators for developing framework agnostic tests
https://github.com/kaosdev/test-decorators
decorators jasmine jest mocha testing typescript unit-testing
Last synced: 22 days ago
JSON representation
Typescript decorators for developing framework agnostic tests
- Host: GitHub
- URL: https://github.com/kaosdev/test-decorators
- Owner: kaosdev
- License: mit
- Created: 2019-10-21T18:10:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:55:17.000Z (almost 2 years ago)
- Last Synced: 2024-10-01T09:43:08.862Z (about 1 month ago)
- Topics: decorators, jasmine, jest, mocha, testing, typescript, unit-testing
- Language: TypeScript
- Size: 669 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Test Decorators
> Typescript decorators for developing framework agnostic tests## Table of Contents
- [Getting Started](#getting-started)
- [Code of Conduct](#code-of-conduct)
- [Contributing](#contributing)
- [License](#license)## Getting Started
### Installing
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/
```### Example Usage (with jest)
First build your suite decorator, using SuiteDecoratorBuilder
```typescript
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
```typescript
@Suite()
class MyTestSuite {
testProp = false;
@BeforeEach() setup() {
this.testProp = true;
}
@It() 'should test'() {
expect(this.testProp).toBeTruthy();
}
}
```### Framework Adapters
The following adapters are available.
- [Jest](packages/jest/README.md)### Build your own adapters
You can extend SuiteFactory to build your own adapters, and provide them to SuiteDecoratorBuilder
```typescript
export class JestSuiteFactory extends SuiteFactory {
buildSuite(target: SuiteTarget): void {
const {suite} = target;
// build your suite with a framework
describe(suite.name, () =>; ...)
}
}```
## [Contributing](CONTRIBUTING.md)
- Read our [code of conduct](CODE_OF_CONDUCT.md)
- Read our [contributing guide](CONTRIBUTING.md)Any contribution following the above guidelines is really appreciated.
## License
test-decorators is [MIT licensed](LICENSE).