Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
520 lines (439 sloc) 14.6 KB
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
<meta name="version" content="S5 1.1" />
<title>Javascript Testing and CI</title>
<meta name="author" content="Kumar McMillan" />
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 6253 2010-03-02 00:24:53Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: left }
/* div.align-center * { */
/* text-align: left } */
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em }
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
<!-- style sheet links -->
<script src="ui/default/slides.js" type="text/javascript"></script>
<link rel="stylesheet" href="ui/default/slides.css"
type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="ui/default/outline.css"
type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="ui/default/print.css"
type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="ui/default/opera.css"
type="text/css" media="projection" id="operaFix" />
<style type="text/css">
#currentSlide {display: none;}
</style>
</head>
<body>
<div class="layout">
<div id="controls"></div>
<div id="currentSlide"></div>
<div id="header">
</div>
<div id="footer">
<h1>Javascript Testing and CI</h1>
</div>
</div>
<div class="presentation">
<div class="slide" id="slide0">
<h1 class="title">Javascript Testing and CI</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Kumar McMillan</td></tr>
<tr class="field"><th class="docinfo-name">Location:</th><td class="field-body">WebDev Barcamp!</td>
</tr>
</tbody>
</table>
</div>
<div class="slide" id="overview">
<h1>Overview</h1>
<ul class="simple">
<li>JavaScript testing for AMO / SUMO<ul>
<li>strategies and patterns</li>
<li>caveats</li>
<li>future enhancements</li>
</ul>
</li>
<li>Integration with CI<ul>
<li>setting up jstestnet</li>
</ul>
</li>
</ul>
</div>
<div class="slide" id="javascript-pattern">
<h1>JavaScript Pattern</h1>
<ul class="simple">
<li>tools: jQuery + plugins</li>
</ul>
<p class="huge">[DOM] &lt;----&gt; [JS behavior]</p>
<ul class="simple">
<li>JS often essential</li>
</ul>
</div>
<div class="slide" id="why-test-javascript">
<h1>Why Test JavaScript?</h1>
<ul class="simple">
<li>errors / timeouts</li>
<li>refactoring</li>
<li>upgrading libraries</li>
<li>understanding your teammate's code</li>
<li>freedom to hack</li>
</ul>
</div>
<div class="slide" id="amo-developer-hub">
<h1>AMO Developer Hub</h1>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold">&lt;div</span> <span style="color: #7D9029">class=</span><span style="color: #BA2121">&quot;trans&quot;</span><span style="color: #008000; font-weight: bold">&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;textarea</span> <span style="color: #7D9029">lang=</span><span style="color: #BA2121">&quot;en-us&quot;</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">&quot;s_en-us&quot;</span><span style="color: #008000; font-weight: bold">&gt;</span>
Firebug integrates with Firefox...
<span style="color: #008000; font-weight: bold">&lt;/textarea&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;textarea</span> <span style="color: #7D9029">lang=</span><span style="color: #BA2121">&quot;ja&quot;</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">&quot;s_ja&quot;</span><span style="color: #008000; font-weight: bold">&gt;</span>
Firebug は、Web ページを閲覧中にクリック一つ
<span style="color: #008000; font-weight: bold">&lt;/textarea&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;/div&gt;</span>
</pre></div>
</div>
<div class="slide" id="test-example">
<h1>Test Example</h1>
<p><a class="reference external" href="http://docs.jquery.com/Qunit">http://docs.jquery.com/Qunit</a></p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">test(<span style="color: #BA2121">&#39;Japanese&#39;</span>, <span style="color: #008000; font-weight: bold">function</span>() {
z.refreshL10n(<span style="color: #BA2121">&#39;ja&#39;</span>);
equals($(<span style="color: #BA2121">&#39;textarea:visible&#39;</span>).text(),
<span style="color: #BA2121">&#39;Firebug は、Web ページを閲覧中にクリック一つ&#39;</span>);
});
</pre></div>
</div>
<div class="slide" id="qunit-test-suite">
<h1>QUnit Test Suite</h1>
<img alt="images/qunit.png" src="images/qunit.png" />
</div>
<div class="slide" id="django-qunit">
<h1>Django-Qunit</h1>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">include('django_qunit.urls')</span></tt></li>
<li><tt class="docutils literal">media/js/tests/yourmodule_tests.js</tt></li>
<li><tt class="docutils literal">media/js/tests/suite.json</tt> :</li>
</ul>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">{<span style="color: #BA2121">&quot;name&quot;</span><span style="color: #666666">:</span> <span style="color: #BA2121">&quot;Test Suite&quot;</span>,
<span style="color: #BA2121">&quot;extra_media_urls&quot;</span><span style="color: #666666">:</span> [
<span style="color: #BA2121">&quot;js/lib/some_library.js&quot;</span>]}
</pre></div>
</div>
<div class="slide" id="mockjax">
<h1>Mockjax</h1>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">asyncTest(<span style="color: #BA2121">&#39;Test validate&#39;</span>, <span style="color: #008000; font-weight: bold">function</span>() {
$.mockjax({
responseText<span style="color: #666666">:</span> {success<span style="color: #666666">:</span> <span style="color: #008000; font-weight: bold">false</span>}
});
validate();
tests.waitFor(<span style="color: #008000; font-weight: bold">function</span>() {
<span style="color: #008000; font-weight: bold">return</span> $(<span style="color: #BA2121">&#39;#result&#39;</span>).length;
}).thenDo(<span style="color: #008000; font-weight: bold">function</span>() {
ok($(<span style="color: #BA2121">&#39;#result&#39;</span>).hasClass(<span style="color: #BA2121">&#39;failed&#39;</span>));
start();
});
});
</pre></div>
</div>
<div class="slide" id="testing-by-event">
<h1>Testing by event</h1>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">test(<span style="color: #BA2121">&#39;Test validate&#39;</span>, <span style="color: #008000; font-weight: bold">function</span>() {
<span style="color: #008000; font-weight: bold">this</span>.sandbox.trigger(<span style="color: #BA2121">&#39;start.validation&#39;</span>,
{success<span style="color: #666666">:</span> <span style="color: #008000; font-weight: bold">true</span>});
ok($(<span style="color: #BA2121">&#39;#result&#39;</span>).hasClass(<span style="color: #BA2121">&#39;passed&#39;</span>));
});
</pre></div>
</div>
<div class="slide" id="caveats">
<h1>Caveats</h1>
<ul class="simple">
<li>fixture HTML vs production<ul>
<li>Django snippets</li>
</ul>
</li>
<li>async :(<ul>
<li>sandbox collisions</li>
<li><tt class="docutils literal"><span class="pre">$('#selector',</span> this.sandbox)</tt></li>
</ul>
</li>
<li>isolated to UI tests<ul>
<li>no database</li>
<li>contrast with Selenium</li>
</ul>
</li>
</ul>
</div>
<div class="slide" id="future-ideas">
<h1>Future Ideas</h1>
<ul class="simple">
<li>Better fixtures (Peter's enhancements?)</li>
<li>Visual test pages</li>
<li>Look at <tt class="docutils literal">manage.py jstest</tt></li>
</ul>
</div>
<div class="slide" id="ci-goal">
<h1>CI Goal</h1>
<img alt="images/ci-goal.png" src="images/ci-goal.png" />
</div>
<div class="slide" id="js-testnet">
<h1>JS TestNet</h1>
<p><a class="reference external" href="https://github.com/kumar303/jstestnet">https://github.com/kumar303/jstestnet</a></p>
<img alt="images/jstestnet.png" src="images/jstestnet.png" />
</div>
<div class="slide" id="id1">
<h1>JS TestNet</h1>
<p>[Demo]</p>
</div>
<div class="slide" id="id2">
<h1>Future Ideas</h1>
<ul class="simple">
<li>prevent caching in &lt;iframe&gt; / &lt;script&gt;<ul>
<li>dev server's responsibility</li>
</ul>
</li>
<li>use socket.io / TornadIO<ul>
<li>cmd line development</li>
</ul>
</li>
</ul>
</div>
<div class="slide" id="that-s-it">
<h1>That's it</h1>
<p>Questions?</p>
<ul class="simple">
<li>AMO's JS test docs: <a class="reference external" href="http://bit.ly/kH4zaR">http://bit.ly/kH4zaR</a></li>
<li><a class="reference external" href="https://github.com/kumar303/jstestnet">https://github.com/kumar303/jstestnet</a></li>
</ul>
</div>
</div>
</body>
</html>