https://github.com/codenameyau/pubtest
:package: Browser console js unit tests
https://github.com/codenameyau/pubtest
Last synced: over 1 year ago
JSON representation
:package: Browser console js unit tests
- Host: GitHub
- URL: https://github.com/codenameyau/pubtest
- Owner: codenameyau
- License: mit
- Created: 2014-08-13T13:12:29.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-02-13T04:52:00.000Z (over 9 years ago)
- Last Synced: 2025-03-01T03:26:12.255Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pubtest
=======
###Description
Write and run JavaScript unit tests in your browser console. It's a quick
way to test ES5 code without a module loader.

Read [src/pubtest.js](https://github.com/codenameyau/pubtest/blob/master/src/pubtest.js#L45-L170) for all available assertions. Docs coming soon...
## Installation
##### Method 1: Manual
Add `build/pubtest.min.js` to your project.
##### Method 2: Bower
```
bower install pubtest --save-dev
```
##Quick Guide
#####`index.html`
```html
```
#####`math.js`
```javascript
var sexyFactorial = function(n) {
return (n < 2) ? 1 : n * sexyFactorial(n-1);
};
```
#####`test-math.js`
```javascript
// Call the test whatever you want
var test = new PubTest('Maths');
// Callback used for local scope
test.testCase(function() {
test.assertEqual(sexyFactorial(0), 1,
'factorial of 0 should equal 1');
test.assertEqual(sexyFactorial(1), 1,
'factorial of 1 should equal 1');
test.assertEqual(sexyFactorial(5), 120,
'factorial of 5 should equal 120');
});
// Show results in browser console (ctr+shift+j)
test.results();
```
### External Examples
- https://github.com/codenameyau/forest-ecosystem/tree/master/public/test