Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreesteve/mocha-ui-tsexports
A class based ui-style for MochaJS
https://github.com/andreesteve/mocha-ui-tsexports
mochajs typescript
Last synced: 9 days ago
JSON representation
A class based ui-style for MochaJS
- Host: GitHub
- URL: https://github.com/andreesteve/mocha-ui-tsexports
- Owner: andreesteve
- License: mit
- Created: 2014-11-16T06:32:28.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-03T05:25:00.000Z (almost 10 years ago)
- Last Synced: 2024-10-18T01:13:27.995Z (28 days ago)
- Topics: mochajs, typescript
- Language: JavaScript
- Size: 645 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mocha-ui-tsexports
==================This mocha UI addon provides a way to represent test cases using classes.
Currently supporting [TypeScript](http://www.typescriptlang.org/) classes compiled as commonJS.
Each class is represented as a test suite, and each method in the class is a test case.Installation
------------npm install mocha-ui-tsexports
Usage
-----Command line:
mocha -u mocha-ui-tsexports [files]
Programmatically:
```javascript
var Mocha = require('mocha');
mocha.ui('mocha-ui-tsexports');
mocha.addFile($TESTFILE$);
mocha.run();
```Example
-------#### TypeScript
Code under test (myProject/src/MyModule.ts):
```typescript
export module MyModule {
export class MyClass {
public myMethod() {
// do my stuff
return 1 + 1;
}
}
}
```Test class (myProject/test/MyTestClass.ts)
```typescript
var MyModule = require('../src/MyModule.ts').MyModule;
var assert = require('assert');export class MyTestClass {
public classSetup() {
// do some prepration before all tests
}
public testSetup() {
// do some preparation before each test
}public myTestMethod() {
assert.equal(new MyModule.MyClass().myMethod(), 2);
}
public testCleanup() {
// do some cleanup after each test
}
public classCleanup() {
// do some cleanup after all tests
}
}
```Then compile and run the tests
```bash
~/project$ tsc src/*.ts test/*.ts --module commonjs
~/project$ mocha -ui mocha-ui-tsexports test/*.js
```