https://github.com/alveflo/ts-unit
typescript testing framework for the c# dudes
https://github.com/alveflo/ts-unit
chai nunit test ts-node ts-unit typescript
Last synced: 4 months ago
JSON representation
typescript testing framework for the c# dudes
- Host: GitHub
- URL: https://github.com/alveflo/ts-unit
- Owner: alveflo
- License: mit
- Created: 2018-10-18T07:52:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T00:35:02.000Z (about 3 years ago)
- Last Synced: 2024-12-15T16:09:58.650Z (4 months ago)
- Topics: chai, nunit, test, ts-node, ts-unit, typescript
- Language: TypeScript
- Size: 48.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cargotest
An experimental, yet functional, chai testing framework to encourage a more NUnit-ish approach to testing in typescript.## Install
```
$ npm install -D cargotest
```
### Global runner
```
$ npm install -g cargotest
```## Setup
`experimentalDecorators` and `emitDecoratorMetadata` needs to be set to true.## Usage
### Runner
The runner is used either by invoking the cli application (`$ cargo`) and the runner will run all tests in `./tests` folder (if `--path` is not provided to cargo cli application).### Test script setup
Package.json
```json
"scripts": {
"test": "./node_modules/.bin/cargo"
}
```### Code usage
Cargotest currently supports `Test` and `TestCase` decorators, as shown below. The decorators is only used to evaluate the corresponding function and that's it. For assertions, use chai.
```typescript
import { assert } from "chai";
class TestClass {
@Test
public When_something_Then_something() {
let foo = new Foo();assert.equal(foo.Bar(), "Bar");
}@Testcase("Darth", "Vader")
@Testcase("Obi wan", "Kenobi")
public When_something_Then_something_else(firstName: string, lastName: string) {
let bar = new Bar();assert.equal(bar.GetLastName(firstName), lastName);
}
}
```# License
MIT