forked from venusjs/venusjs.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocumentation.html
More file actions
197 lines (157 loc) · 8.25 KB
/
documentation.html
File metadata and controls
197 lines (157 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js ie ie6 lte9 lte8 lte7" lang=""><![endif]-->
<!--[if IE 7]><html class="no-js ie ie7 lte9 lte8 lte7" lang=""><![endif]-->
<!--[if IE 8]><html class="no-js ie ie8 lte9 lte8" lang=""><![endif]-->
<!--[if IE 9]><html class="no-js ie ie9 lte9" lang=""><![endif]-->
<!--[if gt IE 9]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<link href="http://fonts.googleapis.com/css?family=Cabin:400,500,600,700" rel="stylesheet" type="text/css">
<!-- <link rel="stylesheet" type="text/css" media="screen" href="/css/all-1365348427000.css"> -->
<link href="/css/main.css" rel="stylesheet" type="text/css">
<link href="/css/venus.css" rel="stylesheet" type="text/css">
</head>
<body>
<header id="global-header">
<div>
<a class="logo" href="/">
<img src="/images/logos/venus.png" alt="Venus.js" />
</a>
<nav>
<ul>
<li><a href="/tutorials">TUTORIALS</a></li>
<li><a href="/documentation">DOCUMENTATION</a></li>
<li><a href="https://groups.google.com/forum/#!forum/venusjs">DISCUSSION</a></li>
</ul>
</nav>
</div>
</header>
<div id="main" role="main">
<article>
<h1>Reference Documentation</h1>
<hr>
<p><h2>Running with Other Libraries</h2></p>
<p><hr/></p>
<p>Venus simplifies running unit tests for JavaScript. To minimize overhead, we set out to create a tool that makes it easier to work with an existing test library such as Mocha, Jasmine or QUnit.</p>
<p><h3>Mocha</h3>
<a href="http://visionmedia.github.com/mocha/" target="_blank"><a href="http://visionmedia.github.com/mocha/">http://visionmedia.github.com/mocha/</a></a></p>
<p>Mocha is a feature-rich test framework that provides a wealth of features, not limited to, but including: async support, watching for slow tests, and integration with various assertion libraries. However, it doesn't contain integration with any browsers (ex. WebKit). By simply adding Venus annotations, you can use Venus to run your tests using PhantomJS, while still being able to run them using the mocha CLI.</p>
<p>Let's say you have this test file, <code>tests.js</code>:</p>
<pre><code class="lang-js">describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
expect([1, 2, 3].indexOf(5)).to.be(-1);
expect([1, 2, 3].indexOf(0)).to.be(-1);
});
});
});</code></pre>
<p>In order to make <code>tests.js</code> runnable in Venus, modify your file as follows:</p>
<pre><code class="lang-js">/**
* @venus-library mocha
* @venus-template sandbox
*/
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
expect([1, 2, 3].indexOf(5)).to.be(-1);
expect([1, 2, 3].indexOf(0)).to.be(-1);
});
});
});</code></pre>
<p>NOTE: This file uses <code>expect.js</code>, but can be modified to use any assertion library supported by Mocha.</p>
<p>Now you can run your tests using Venus:</p>
<pre><code class="lang-bash">$ venus run -t tests.js -n
info: Serving test: http://localhost:2013/venus-core/1
info: executor started on localhost:2013
info: Phantom browser is loading http://localhost:2013/venus-core/1
--------------------------------------------------------
PhantomJS/1.7.0
Array >> #indexOf()
✓ should return -1 when the value is not present
✓ 1 test completed (0.01ms)</code></pre>
<p><h3>Jasmine</h3>
<a href="http://pivotal.github.com/jasmine/" target="_blank"><a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a></a></p>
<p>Jasmine is a behavior-driven development framework for testing JavaScript code. By default, it includes an HTML file that serves as a test runner. However, it doesn't provide a command-line interface to run your unit tests. By simply adding Venus annotations, you can use Venus to run your tests both from the command line, while still preserving the ability to use the HTML test runner.</p>
<p>Let's say you have this file, <code>tests.js</code>:</p>
<pre><code class="lang-js">describe('A suite', function() {
it('contains spec with an expectation', function() {
expect(true).toBe(true);
});
});</code></pre>
<p>In order to make <code>tests.js</code>: runnable in Venus, modify your file as follows:</p>
<pre><code class="lang-js">/**
* @venus-library jasmine
* @venus-template sandbox
*/
describe('A suite', function() {
it('contains spec with an expectation', function() {
expect(true).toBe(true);
});
});</code></pre>
<p>Now you can run your tests using Venus:</p>
<pre><code class="lang-bash">$ venus run -t tests.js -n
info: Serving test: http://localhost:2013/venus-core/1
info: executor started on localhost:2013
info: Phantom browser is loading http://localhost:2013/venus-core/1
--------------------------------------------------------
PhantomJS/1.7.0
A suite
✓ contains spec with an expectation
✓ 1 test completed (0ms)</code></pre>
<p><h3>QUnit</h3>
<a href="http://qunitjs.com/" target="_blank"><a href="http://qunitjs.com/">http://qunitjs.com/</a></a></p>
<p>QUnit is a JavaScript unit test suite used by jQuery, jQuery UI, and jQuery Mobile. It provides a web page interface for running your unit tests. However, it doesn't provide a command-line interface to run your unit tests. By simply adding Venus annotations, you can use Venus to run your tests both from the command line, while still preserving the ability to use the web page interface.</p>
<p>Let's say you have this test file, <code>tests.js</code>:</p>
<pre><code class="lang-js">test( "hello test", function() {
ok( 1 == "1", "Passed!" );
});</code></pre>
<p>In order to make <code>tests.js</code> runnable in Venus, modify your file as follows:</p>
<pre><code class="lang-js">/**
* @venus-library qunit
* @venus-template sandbox
*/
test( "hello test", function() {
ok( 1 == "1", "Passed!" );
});</code></pre>
<p>Now you can run your tests using Venus:</p>
<pre><code class="lang-bash">$ venus run -t tests.js -n
info: Serving test: http://localhost:2013/venus-core/1
info: executor started on localhost:2013
info: Phantom browser is loading http://localhost:2013/venus-core/1
--------------------------------------------------------
PhantomJS/1.7.0
hello test
✓ Passed!
✓ 1 test completed (20ms)</code></pre>
</article>
</div>
<footer id="global-footer">
<div>
<p class="copyright">
LinkedIn Corporation © 2013
</p>
<ul>
<li><a href="http://www.github.com/linkedin/venus.js">GitHub</a></li>
<li><a href="https://github.com/linkedin/venus.js/issues?state=open">Issue Tracker</a></li>
<li><a href="https://github.com/linkedin/venus.js/blob/master/CHANGELOG.md">CHANGELOG</a></li>
<li><a href="https://github.com/linkedin/venus.js/blob/master/CONTRIBUTING.md">Contributing</a></li>
</ul>
<p class="social-actions">
<iframe width="112px" scrolling="0" height="20px" frameborder="0" allowtransparency="true" src="http://ghbtns.com/github-btn.html?user=linkedin&repo=venus.js&type=watch&count=true"></iframe>
<iframe width="98px" scrolling="0" height="20px" frameborder="0" allowtransparency="true" src="http://ghbtns.com/github-btn.html?user=linkedin&repo=venus&type=fork&count=true"></iframe>
</p>
</div>
</footer>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/venus.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36360221-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>