-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
152 lines (127 loc) · 15.1 KB
/
index.html
File metadata and controls
152 lines (127 loc) · 15.1 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
<link rel="stylesheet" href="/static/normalize.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/static/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/static/gh-fork-ribbon.css" type="text/css" media="screen" />
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/static/bug-icon-black.ico">
<title>Unexpected</title>
</head>
<body class="sidebar-hidden theme-dark" data-sidebar="false">
<header>
<div class="logo-icon"></div>
<nav>
<ul>
<li class="menu-toggle-item">
<button class="menu-toggle" onclick="toggleSidebar()"></button>
</li>
<li class="active"><a href="/">Unexpected</a></li>
<li class=""><a href="/assertions/any/to-be/">Assertions</a></li>
<li class=""><a href="/api/addAssertion/">API</a></li>
<li class=""><a href="/./plugins/">Plugins</a></li>
</ul>
</nav>
<div class="search" style="visibility: hidden">
<input id="search" placeholder="Search..." value="">
<div id="searchDropDown" class="dropDown">
<ul id="searchResults"></ul>
</div>
</div>
</header>
<div class="main" tabindex="-1">
<div class="content">
<html><head></head><body><h1 id="welcome-to-unexpected">Welcome to Unexpected</h1>
<h1 id="the-extensible-bdd-assertion-toolkit">The extensible BDD assertion toolkit</h1>
<pre class="code lang-javascript"><div><span style="color: #F92672">const</span> library <span style="color: #F92672">=</span> <span style="color: #999">{</span></div><div> <span style="color: #66D9EF; font-weight: bold">name</span><span style="color: #F92672">:</span> <span style="color: #E6DB74">'un3xp3c73d'</span><span style="color: #999">,</span></div><div> <span style="color: #66D9EF; font-weight: bold">created</span><span style="color: #F92672">:</span> <span style="color: #66D9EF; font-weight: bold">2013</span><span style="color: #999">,</span></div><div> <span style="color: #66D9EF; font-weight: bold">site</span><span style="color: #F92672">:</span> <span style="color: #E6DB74">'https://unexpected.js.org'</span><span style="color: #999">,</span></div><div><span style="color: #999">};</span></div><div> </div><div>expect<span style="color: #999">(</span>library<span style="color: #999">,</span> <span style="color: #E6DB74">'to satisfy'</span><span style="color: #999">,</span> <span style="color: #999">{</span></div><div> <span style="color: #66D9EF; font-weight: bold">name</span><span style="color: #F92672">:</span> <span style="color: #E6DB74">'Unexpected'</span><span style="color: #999">,</span></div><div> <span style="color: #66D9EF; font-weight: bold">created</span><span style="color: #F92672">:</span> <span style="color: #66D9EF; font-weight: bold">2013</span><span style="color: #999">,</span></div><div><span style="color: #999">});</span></div></pre>
<pre class="output"><div><span style="color: #F92672; font-weight: bold">expected</span> { <span style="color: #CCC">name</span>: <span style="color: #E6DB74">'un3xp3c73d'</span>, <span style="color: #CCC">created</span>: <span style="color: #66D9EF">2013</span>, <span style="color: #CCC">site</span>: <span style="color: #E6DB74">'https://unexpected.js.org'</span> }</div><div><span style="color: #F92672; font-weight: bold">to satisfy</span> { <span style="color: #CCC">name</span>: <span style="color: #E6DB74">'Unexpected'</span>, <span style="color: #CCC">created</span>: <span style="color: #66D9EF">2013</span> }</div><div> </div><div>{</div><div> <div style="display: inline-block; vertical-align: top"><div><span style="color: #CCC">name</span>: <div style="display: inline-block; vertical-align: top"><div><span style="color: #E6DB74">'un3xp3c73d'</span>, <div style="display: inline-block; vertical-align: top"><div><span style="color: #F92672; font-weight: bold">//</span></div><div><span style="color: #F92672; font-weight: bold">//</span></div><div><span style="color: #F92672; font-weight: bold">//</span></div><div><span style="color: #F92672; font-weight: bold">//</span></div></div> <div style="display: inline-block; vertical-align: top"><div><span style="color: #F92672; font-weight: bold">should equal</span> <div style="display: inline-block; vertical-align: top"><div><span style="color: #E6DB74">'Unexpected'</span></div></div></div><div> </div><div><span style="background-color: #F92672; color: black">un3xp3c73d</span></div><div><span style="background-color: #A6E22E; color: black">Unexpected</span></div></div></div></div></div></div></div><div> <div style="display: inline-block; vertical-align: top"><div><span style="color: #CCC">created</span>: <span style="color: #66D9EF">2013</span>,</div></div></div><div> <div style="display: inline-block; vertical-align: top"><div><span style="color: #CCC">site</span>: <span style="color: #E6DB74">'https://unexpected.js.org'</span></div></div></div><div>}</div></pre>
<h2 id="badges">Badges</h2>
<p><a href="https://www.npmjs.com/package/unexpected"><img src="https://badge.fury.io/js/unexpected.svg" alt="NPM version"></a>
<a href="https://github.com/unexpectedjs/unexpected/actions"><img src="https://github.com/unexpectedjs/unexpected/workflows/Tests/badge.svg" alt="Build Status"></a>
<a href="https://coveralls.io/github/unexpectedjs/unexpected"><img src="https://coveralls.io/repos/unexpectedjs/unexpected/badge.svg" alt="Coverage Status"></a>
<a href="https://gitter.im/unexpectedjs/unexpected?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter"></a>
<a href="https://github.com/unexpectedjs/unexpected"><img src="https://img.shields.io/github/stars/unexpectedjs/unexpected.svg?label=Star&maxAge=2592000&style=flat" alt="Github"></a></p>
<h2 id="features">Features</h2>
<ul>
<li>Extensible</li>
<li>Fast</li>
<li>Provides really nice error messages</li>
<li>Helps if you misspell assertions</li>
<li>Compatible with all test frameworks</li>
<li>Node.js ready (<code>require('unexpected')</code>)</li>
<li>Supports <a href="api/addAssertion/#asynchronous-assertions">asynchronous assertions using promises</a></li>
<li>Single global with no prototype extensions or shims</li>
<li>Cross-browser: works on Chrome, Firefox, Safari, Opera, IE11, Edge</li>
</ul>
<h3 id="node">Node</h3>
<p>Install it with NPM or add it to your <code>package.json</code>:</p>
<pre class="code lang-"><div>$ npm install --save-dev unexpected</div></pre>
<p>Then:</p>
<pre class="code lang-javascript"><div><span style="color: #F92672">const</span> expect <span style="color: #F92672">=</span> require<span style="color: #999">(</span><span style="color: #E6DB74">'unexpected'</span><span style="color: #999">);</span></div></pre>
<h3 id="browser">Browser</h3>
<p>Include <code>unexpected.js</code>.</p>
<pre class="code lang-html"><div><span style="color: #999"><</span><span style="color: #66D9EF; font-weight: bold">script </span><span style="color: #E6DB74">src</span><span style="color: #999">="</span><span style="color: #F92672">unexpected.js</span><span style="color: #999">"></</span><span style="color: #66D9EF; font-weight: bold">script</span><span style="color: #999">></span></div></pre>
<p>This will expose the <code>expect</code> function under the following namespace:</p>
<pre class="code lang-javascript"><div><span style="color: #F92672">const</span> expect <span style="color: #F92672">=</span> weknowhow<span style="color: #999">.</span>expect<span style="color: #999">;</span></div></pre>
<h3 id="requirejs">RequireJS</h3>
<p>Include the library with RequireJS the following way:</p>
<pre class="code lang-javascript"><div>require<span style="color: #999">.</span>config<span style="color: #999">({</span></div><div> <span style="color: #66D9EF; font-weight: bold">paths</span><span style="color: #F92672">:</span> <span style="color: #999">{</span></div><div> <span style="color: #66D9EF; font-weight: bold">unexpected</span><span style="color: #F92672">:</span> <span style="color: #E6DB74">'path/to/unexpected'</span><span style="color: #999">,</span></div><div> <span style="color: #999">},</span></div><div><span style="color: #999">});</span></div><div> </div><div>define<span style="color: #999">([</span><span style="color: #E6DB74">'unexpected'</span><span style="color: #999">],</span> <span style="color: #F92672">function</span> <span style="color: #999">(</span>expect<span style="color: #999">)</span> <span style="color: #999">{</span></div><div> <span style="color: #888">// Your code</span></div><div><span style="color: #999">});</span></div></pre>
<h2 id="using-unexpected-with-a-test-framework">Using Unexpected with a test framework</h2>
<p>For example, if you create a test suite with
<a href="https://github.com/mochajs/mocha">mocha</a>.</p>
<p>Let's say we wanted to test the following program:</p>
<p><strong>math.js</strong></p>
<pre class="code lang-javascript"><div><span style="color: #F92672">function</span> add<span style="color: #999">(</span>a<span style="color: #999">,</span> b<span style="color: #999">)</span> <span style="color: #999">{</span></div><div> <span style="color: #F92672">return</span> a <span style="color: #F92672">+</span> b<span style="color: #999">;</span></div><div><span style="color: #999">}</span></div></pre>
<p>Our test file would look like this:</p>
<pre class="code lang-javascript"><div>describe<span style="color: #999">(</span><span style="color: #E6DB74">'math.js'</span><span style="color: #999">,</span> <span style="color: #F92672">function</span> <span style="color: #999">()</span> <span style="color: #999">{</span></div><div> describe<span style="color: #999">(</span><span style="color: #E6DB74">'add'</span><span style="color: #999">,</span> <span style="color: #F92672">function</span> <span style="color: #999">()</span> <span style="color: #999">{</span></div><div> it<span style="color: #999">(</span><span style="color: #E6DB74">'is a function'</span><span style="color: #999">,</span> <span style="color: #F92672">function</span> <span style="color: #999">()</span> <span style="color: #999">{</span></div><div> expect<span style="color: #999">(</span>add<span style="color: #999">,</span> <span style="color: #E6DB74">'to be a'</span><span style="color: #999">,</span> <span style="color: #E6DB74">'function'</span><span style="color: #999">);</span></div><div> <span style="color: #999">});</span></div><div> </div><div> it<span style="color: #999">(</span><span style="color: #E6DB74">'adds numbers'</span><span style="color: #999">,</span> <span style="color: #F92672">function</span> <span style="color: #999">()</span> <span style="color: #999">{</span></div><div> expect<span style="color: #999">(</span>add<span style="color: #999">(</span><span style="color: #66D9EF; font-weight: bold">1</span><span style="color: #999">,</span> <span style="color: #66D9EF; font-weight: bold">3</span><span style="color: #999">),</span> <span style="color: #E6DB74">'to be'</span><span style="color: #999">,</span> <span style="color: #66D9EF; font-weight: bold">4</span><span style="color: #999">);</span></div><div> <span style="color: #999">});</span></div><div> <span style="color: #999">});</span></div><div><span style="color: #999">});</span></div></pre>
<p>If a certain expectation fails, an exception will be raised which gets captured
and shown/processed by the test runner.</p>
<h2 id="source">Source</h2>
<p>The source for Unexpected can be found on
<a href="https://github.com/unexpectedjs/unexpected">Github</a>.</p>
<h2 id="releases">Releases</h2>
<p>See <a href="releases">the releases page</a>.</p>
<h2 id="configure-the-error-output">Configure the error output</h2>
<h3 id="disable-stack-trace-trimming">Disable stack trace trimming</h3>
<p>You can disable stack trace trimming the following way:</p>
<pre class="code lang-"><div>UNEXPECTED_FULL_TRACE=true mocha</div></pre>
<p>You can achieve the same in the browser by setting the query parameter
<code>full-trace</code> to <code>true</code>.</p>
<h3 id="controlling-the-inspection-depth">Controlling the inspection depth</h3>
<p>To change the level subtrees gets dotted out, you can set the inspection depth
the following way:</p>
<pre class="code lang-"><div>UNEXPECTED_DEPTH=9 mocha</div></pre>
<p>You can achieve the same in the browser by setting the query parameter <code>depth</code>
to the inspection depth you want.</p>
<h2 id="mit-license">MIT License</h2>
<p>Copyright (c) 2013 Sune Simonsen <a href="mailto:sune@we-knowhow.dk">mailto:sune@we-knowhow.dk</a></p>
<p>Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:</p>
<p>The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
</body></html>
</div>
<a class="github-fork-ribbon" href="https://github.com/unexpectedjs/unexpected" data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
</div>
<script type="text/javascript">
baseUrl = '/';
</script>
<script type="text/javascript" src="/static/toggleSidebar.js"></script>
<script type="text/javascript" src="/static/rememberScrollPosition.js"></script>
<script type="text/javascript" src="/static/focusMain.js"></script>
<script type="text/javascript" src="/static/search.js"></script>
</body>
</html>