https://github.com/numtel/velocity-tinytest
Use Tinytest with Velocity
https://github.com/numtel/velocity-tinytest
Last synced: about 1 year ago
JSON representation
Use Tinytest with Velocity
- Host: GitHub
- URL: https://github.com/numtel/velocity-tinytest
- Owner: numtel
- License: mit
- Created: 2014-10-22T04:51:08.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-05T21:58:18.000Z (over 11 years ago)
- Last Synced: 2025-02-15T04:42:29.697Z (about 1 year ago)
- Language: CoffeeScript
- Size: 137 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# numtel:velocity-tinytest
Use Tinytest to test your Meteor app, just like you would a package.
If you would like to use Tinytest with your app but without Velocity, see my
[numtel:tinytest-in-app](https://github.com/numtel/tinytest-in-app) package.
## Installation
**This package has been removed from Atmosphere due to breaking changes in Velocity's API.**
The `tinytest` package is included automatically.
## Quick start
1. Add a test to a `.js` or `.coffee` file inside `tests/tinytest`
```javascript
Tinytest.add('test title', function(test){
test.equal(true, true);
});
```
2. To view the results, install the Velocity HTML Reporter:
```bash
$ meteor add velocity:html-reporter
```
## Tinytest documentation
Since there is no official documentation for Tinytest, it may be helpful to have
some here.
Test titles can be any string. Use a separator of `" - "` to define sections.
**Test Syntax:**
```javascript
// Synchronous test
Tinytest.add('test title', function(test){
test.equal(true, true);
});
// Asynchronous test
Tinytest.addAsync('async test title', function(test, onComplete){
Meteor.setTimeout(function(){
test.equal(true, true);
onComplete();
}, 1000);
});
```
**Assertions:**
```javascript
test.isFalse(v, msg) // if (!v)
test.isTrue(v, msg) // if(v)
test.equal(actual, expected, message)
test.notEqual(actual, expected, message)
test.length(obj, len, msg)
test.include(s, v) // s = string or object
test.isNaN(v, msg)
test.isUndefined(v, msg)
test.isNotNull(v, msg)
test.isNull(v, msg)
// expected can be:
// undefined: accept any exception.
// string: pass if the string is a substring of the exception message.
// regexp: pass if the exception message passes the regexp.
// function: call the function as a predicate with the exception.
test.throws(func, expected)
test.instanceOf(obj, klass)
test.runId() // Unique id for this test run
// Call this to fail the test with an exception. Use this to record
// exceptions that occur inside asynchronous callbacks in tests.
//
// It should only be used with asynchronous tests, and if you call
// this function, you should make sure that (1) the test doesn't
// call its callback (onComplete function); (2) the test function
// doesn't directly raise an exception.
test.exception(exception)
test.expect_fail()
```
## Related packages
* [numtel:tinytest-fixture-account](http://github.com/numtel/tinytest-fixture-account) - Create a fixture account for tests, remove when done
* [numtel:tinytest-in-app](https://github.com/numtel/tinytest-in-app) - Use Tinytest in a Meteor app without Velocity
## Todo
* Make tests post results one at a time as they come in instead of in big groups after each location (Server/Client)
## License
MIT