<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Untitled RSS Feed]]></title><description><![CDATA[Untitled RSS Feed]]></description><link>https://ciena-blueplanet.github.io/developers.blog</link><generator>RSS for Node</generator><lastBuildDate>Thu, 29 Jun 2017 16:14:51 GMT</lastBuildDate><atom:link href="https://ciena-blueplanet.github.io/developers.blog/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Faster acceptance tests]]></title><description><![CDATA[<div class="paragraph">
<p>You may have noticed that when working with <code>ember-cli-mocha</code>, acceptance tests created with</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>ember g acceptance-test &lt;name&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Can run rather slowly if you use proper BDD ettiquette and include an <code>it()</code> for every <code>expect()</code>. This is due primarily to the fact that the application is created in a top-level <code>beforeEach()</code> and destroyed in a top-level <code>afterEach()</code> While this makes your tests very nicely independent, it can also make your tests rather slow, since the app is created and your route rendererd independently for each <code>it()</code>.</p>
</div>
<div class="paragraph">
<p>If you&#8217;re like me, you often set up a scenario in your <code>beforeEach()</code> and then have a few different things you want to verify expected behavior for, without changing the state of your application. In cases like those, what you really want is <code>before()</code> and <code>after()</code> instead of <code>beforeEach()</code> and <code>afterEach()</code>. Inside a <code>describe()</code>, <code>before()</code> is executed once, then all the <code>it()</code> methods are executed, then the <code>after()</code> is executed once. On the other hand, as the name suggests <code>beforeEach()</code> is exectued before each individual <code>it()</code> method and <code>afterEach()</code> is executed after each individual <code>it()</code> method.</p>
</div>
<div class="paragraph">
<p>So, what happens when the following test is run?</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js">import {afterEach, beforeEach, describe, it} from 'mocha'
import {expect} from 'chai'
import startApp from '../../../helpers/start-app'
import destroyApp from '../../../helpers/destroy-app'

describe('Acceptance: Login page shows form', function () {
  let application

  beforeEach(function () {
    application = startApp()
    visit('/login')
  })

  afterEach(function () {
    destroyApp(application)
  })

  it('should display the company logo', function () {
    expect(find('img.logo')).to.have.length(1)
  })

  it('should display a username input', function () {
    expect(find('input[type=text].username')).to.have.length(1)
  })

  it('should display a password input', function () {
    expect(find('input[type=password].password')).to.have.length(1)
  })
})</code></pre>
</div>
</div>
<div class="paragraph">
<p>Well, since we&#8217;re using the default <code>beforeEach()</code> to perform the <code>startApp()</code> call, and we have 3 <code>it()</code> methods, the app is being created 3 times, and each time a single expectation is being verified.</p>
</div>
<div class="paragraph">
<p>Now, you may be thinking, if I want to speed that up, all I have to do is combine the <code>it()</code> methods. After all, <code>beforeEach()</code> will run once for each <code>it()</code>, so if I only want it to run once, I should just have a single <code>it()</code>.</p>
</div>
<div class="paragraph">
<p>Seems logical&#8230;&#8203; right?</p>
</div>
<div class="paragraph">
<p>Wrong.</p>
</div>
<div class="paragraph">
<p>Don&#8217;t do that.</p>
</div>
<div class="paragraph">
<p>No one wants to see this test:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js">import {afterEach, beforeEach, describe, it} from 'mocha'
import {expect} from 'chai'
import startApp from '../../../helpers/start-app'
import destroyApp from '../../../helpers/destroy-app'

describe('Acceptance: Login page shows form', function () {
  let application

  beforeEach(function () {
    application = startApp()
    visit('/login')
  })

  afterEach(function () {
    destroyApp(application)
  })

  it('should render the logo and login form', function () {
    expect(find('img.logo')).to.have.length(1)
    expect(find('input[type=text].username')).to.have.length(1)
    expect(find('input[type=password].password')).to.have.length(1)
  })
})</code></pre>
</div>
</div>
<div class="olist arabic">
<div class="title">And here&#8217;s why:</div>
<ol class="arabic">
<li>
<p>It doesn&#8217;t read well.</p>
</li>
<li>
<p>Failures are difficult to track down</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Sure, you can try to mitigate #2 by doing something like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js">import {afterEach, beforeEach, describe, it} from 'mocha'
import {expect} from 'chai'
import startApp from '../../../helpers/start-app'
import destroyApp from '../../../helpers/destroy-app'

describe('Acceptance: Login page shows form', function () {
  let application

  beforeEach(function () {
    application = startApp()
    visit('/login')
  })

  afterEach(function () {
    destroyApp(application)
  })

  it('should render the logo and login form', function () {
    expect(
      find('img.logo'),
      'the logo should be shown'
    ).to.have.length(1)

    expect(
      find('input[type=text].username'),
      'the username input should be shown'
    ).to.have.length(1)

    expect(
      find('input[type=password].password'),
      'the password input should be shown'
    ).to.have.length(1)
  })
})</code></pre>
</div>
</div>
<div class="paragraph">
<p>But really, you can&#8217;t honestly tell me that&#8217;s easy to read/follow.</p>
</div>
<div class="paragraph">
<p>Instead, embrace the power of <code>before()</code> and speed up your test without losing readability or ease of debugging:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-js" data-lang="js">import {after, before, describe, it} from 'mocha'
import {expect} from 'chai'
import startApp from '../../../helpers/start-app'
import destroyApp from '../../../helpers/destroy-app'

describe('Acceptance: Login page shows form', function () {
  let application

  before(function () {
    application = startApp()
    visit('/login')
  })

  after(function () {
    destroyApp(application)
  })

  it('should display the company logo', function () {
    expect(find('img.logo')).to.have.length(1)
  })

  it('should display a username input', function () {
    expect(find('input[type=text].username')).to.have.length(1)
  })

  it('should display a password input', function () {
    expect(find('input[type=password].password')).to.have.length(1)
  })
})</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now what&#8217;s happening. Well, since <code>before()</code> runs before <strong>all</strong> <code>it()</code> methods, and <code>after()</code> runs after <strong>all</strong> <code>it()</code> methods, we have a single app instance being created, and then three expectations happening before the app instance is destroyed.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<strong>WARNING</strong>: Creating your app in <code>before()</code> means that all your nested functionality is using the same app, with the same state. So, if you click a check-box in one test, it&#8217;ll stay clicked for the next test unless you reset your state somehow!
</td>
</tr>
</table>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>The above limitation means you have two options when writing acceptance tests, since I don&#8217;t consider having to clean up after yourself after every interaction with your app a valid option.</p>
</div>
<div class="paragraph">
<p>The first option is to create a new <code>describe()</code> with it&#8217;s own <code>startApp()</code> and <code>destroyApp()</code> for each interaction you want to test. This is a valid option in many situations, but may not be as desirable in others.</p>
</div>
<div class="paragraph">
<p>The second option is to use another mechanism to reset your state to a known starting point before beginning to interact with your application. For instance, you could use <code>visit()</code> to navigate to another route (preferably a very easy to load one, like <code>not-found</code>) and then navigate back to the current route (effectively doing a refresh).</p>
</div>
</div>
</div>]]></description><link>https://ciena-blueplanet.github.io/developers.blog/2016/08/24/Faster-acceptance-tests.html</link><guid isPermaLink="true">https://ciena-blueplanet.github.io/developers.blog/2016/08/24/Faster-acceptance-tests.html</guid><category><![CDATA[mocha]]></category><category><![CDATA[ ember]]></category><category><![CDATA[ testing]]></category><category><![CDATA[ acceptance]]></category><dc:creator><![CDATA[Adam Meadows]]></dc:creator><pubDate>Wed, 24 Aug 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Using ember-cli-visual-acceptance]]></title><description><![CDATA[<div class="sect1">
<h2 id="_installation">Installation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Simple as running <code>ember install ember-cli-visual-acceptance</code></p>
</div>
<div class="sect2">
<h3 id="_testem_json">Testem.json</h3>
<div class="paragraph">
<p>In order for <code>ember-cli-visual-acceptance</code> to capture images, <code>"launch_in_ci"</code> must contain ethier <code>SlimerJsVisualAcceptance</code> or <code>PhantomJsVisualAcceptance</code>.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-json" data-lang="json">{
  "framework": "mocha",
  "test_page": "tests/index.html?hidepassed",
  "disable_watching": true,
  "launch_in_ci": [
    "SlimerJsVisualAcceptance"
  ],
  "launch_in_dev": [
    "Firefox"
  ],
  "launchers": {
    "PhantomJsVisualAcceptance": {
      "command": "phantomjs vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    },
    "SlimerJsVisualAcceptance": {
      "command": "slimerjs -jsconsole vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    }
  }
}</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_usage">Usage</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Inside an integration or acceptance test you can use <code>return capture('&lt;image-label&gt;')</code> at the end of an <code>it()</code> function.</p>
</div>
<div class="listingblock">
<div class="title">test.js</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">it('renders', function () {
  // Set any properties with this.set('myProperty', 'value')
  // Handle any actions with this.on('myAction', function (val) { ... })

  this.render(hbs`{{frost-file-picker}}`)
  expect(this.$('.frost-file-picker')).to.have.length(1)
  return capture('Basic-File-Picker')
})</code></pre>
</div>
</div>
<div class="literalblock">
<div class="content">
<pre>You can also use this functionality for async testing:</pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">it('renders', function (done) {
  // Set any properties with this.set('myProperty', 'value')
  // Handle any actions with this.on('myAction', function (val) { ... })

  this.render(hbs`{{frost-file-picker}}`)
  expect(this.$('.frost-file-picker')).to.have.length(1)
  capture('Basic-File-Picker').then(function (data) {
    console.log(arguments)
    done()
  }).catch(function (err) {
    done(err)
  })
})</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this case done comes from <code>it('test', function (done) { &#8230;&#8203; }</code>. You can also use the <code>then</code> functionality to get creative rather than using done.
<code>arguments</code> will display the response from ResembleJS or the message, <code>'No passed image. Saving current test as base'</code> (If there is no current baseline image).</p>
</div>
<div class="sect2">
<h3 id="_usage_with_qunit">Usage with Qunit</h3>
<div class="paragraph">
<p>To use with Qunit you must supply the <code>assert</code> parameter.</p>
</div>
<div class="paragraph">
<p>Example (Using <a href="https://github.com/gcollazo/ember-cli-showdown/blob/master/tests/integration/components/markdown-to-html-test.js">ember-cli-showdown</a>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import hbs from 'htmlbars-inline-precompile';
import { moduleForComponent, test } from 'ember-qunit';

moduleForComponent('markdown-to-html', 'Integration | Component | markdown to html', {
  integration: true
});

test('positional parameter', function(assert) {
  assert.expect(1);
  this.set('markdown', '*hello world*');
  this.render(hbs`{{markdown-to-html markdown}}`);
  assert.equal(this.$('&gt; *').html(), '&lt;p&gt;&lt;em&gt;hello world&lt;/em&gt;&lt;/p&gt;');
  return capture('Markdown', {assert: assert});
});</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_larger_frame">Larger frame</h4>
<div class="paragraph">
<p>In order to go beyond the default 640x340px dimensions you can supply the width and height to the capture function. The following shows an example to get a 1920x4041 container: <code>capture('&lt;image-label&gt;', {width: 1920, height: 4041}))</code>.</p>
</div>
</div>
<div class="sect3">
<h4 id="_targeting_an_element">Targeting an element</h4>
<div class="paragraph">
<p>ember-cli-visual-acceptance also has the ability to target a specific element. Given a DOM element ember-cli-visual-acceptance will capture the specified element rather than the default <code>#ember-testing-container</code>. To target an element you must pass in the DOM element.</p>
</div>
<div class="sect4">
<h5 id="_target_with_an_id">Target with an id</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">capture('Markdown', { targetElement: document.getElementById('foo')});</code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="_target_with_class_selectors">Target with class selectors</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">capture('drop-down-container', { targetElement: this.$('.drop-down-container')[0]})</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_setting_up_travis">Setting up travis</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Replace <code>ember test</code> with <code>ember tva</code>. This command comes with <code>ember-cli-visual-acceptance</code> and provides the functionality for commenting  a report (Stored on Imgur) on a PR from the Travis build.</p>
</div>
<div class="paragraph">
<p>Add your github credentials to <code>before_script:</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-yaml" data-lang="yaml">before_script:
- git config --global user.email "ericwhite613@gmail.com"
- git config --global user.name "Eric White"
- git config --global push.default simple
- npm set progress=false
- git config credential.helper "store --file=.git/credentials"
- echo "https://${GH_TOKEN}:@github.com" &gt; .git/credentials</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Secure Variables (Display value in build log = <code>OFF</code>)</strong></p>
</div>
<div class="ulist">
<ul>
<li>
<p>Add <code>GH_TOKEN</code> to Travis. Personal Access Token must have push access</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><strong>Unsecure Variables (Display value in build log = <code>ON</code>)</strong></p>
</div>
<div class="ulist">
<ul>
<li>
<p>Add <code>RO_GH_TOKEN</code> Unsecure token that can only read.</p>
</li>
<li>
<p>Add <code>VISUAL_ACCEPTANCE_TOKEN</code> token, value can be found <a href="https://travis-ci.org/ciena-blueplanet/ember-cli-visual-acceptance/builds/234089652#L261">here</a></p>
</li>
<li>
<p>If you put the <code>VISUAL_ACCEPTANCE_TOKEN</code> directly in your code and commit it to Github; Github will revoke the token. So it may be smart for you to create your own dummy Github account, and create a personal access token that has it&#8217;s repo scope set.</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_pushing_only_when_conditions_are_met">Pushing only when conditions are met</h3>
<div class="paragraph">
<p>In some instances you may have multiple jobs with your Travis Builds. Wishing only to push in one. Ember-cli-visual-acceptance has added two options to <code>ember tva</code>, <code>push-var</code> and <code>push-on</code>. Using these two options visual acceptance will only push when <code>push-var</code> is equal to <code>push-on</code>. For instance we could do <code>ember tva --push-var=$EMBER_TRY_SCENARIO --push-on=default</code>, so visual acceptance will only push when doing the build job for <code>EMBER_TRY_SCENARIO=default</code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_playing_nice_with_pr_bumper_or_doing_your_own_push">Playing nice with Pr-bumper or doing your own push</h3>
<div class="paragraph">
<p>Using <code>push-var</code> and <code>push-on</code> we can also stop visual-acceptance from pushing and having only pr-bumper or something else push. This can be accomplished with the following: <code>ember tva --push-var='false'</code></p>
</div>
</div>
<div class="sect2">
<h3 id="_github_enterprise">Github Enterprise</h3>
<div class="paragraph">
<p>The api endpoint can be specified with the <code>--github-api-endpoint="http(s)://hostname/api/v3"</code> option</p>
</div>
</div>
<div class="sect2">
<h3 id="_nightmarejs_electron_vs_browsers_html2canvas_vs_phantomjs_render_callback">NightmareJS (Electron) vs Browsers - html2canvas vs. PhantomJS render callback</h3>
<div class="paragraph">
<p>You must enable the display to use headless browsers by adding the following to the <code>before_script</code> hook:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-yaml" data-lang="yaml">before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_nightmarejs_electron">NightmareJS (Electron)</h4>
<div class="paragraph">
<p><a href="https://github.com/segmentio/nightmare">Nightmare</a> takes a screenshot with Electron and provides the most accurate image. Using nightmare requires the <code>nightmare</code> and <code>nightmare-custom-event</code> packages to be saved to your dev dependencies <code>npm install nightmare nightmare-custom-event --save-dev</code> (if using the visual acceptance blueprint this will be automatic)</p>
</div>
<div class="paragraph">
<p>If a captured image comes up blank or cutoff you should edit the <code>vendor/nightmarejs-launcher.js</code> file to increase the viewport (the default is <code>.viewport(3000, 10000)</code> width by height). The reason for this is Electron can only screenshot what it can see, and the test page continously grows with the more tests you have. This solution costs less than attempting to scroll the ember testing rectangle in frame, and resizing Electron to fit the image. Additionally, as long as Nightmare&#8217;s <code>show</code> option is not set to <code>true</code> you can get away with setting ludicrous sizes.</p>
</div>
</div>
<div class="sect3">
<h4 id="_phantomjs_slimerjs">PhantomJS - SlimerJS</h4>
<div class="paragraph">
<p><a href="http://phantomjs.org/">PhantomJS</a> and <a href="https://slimerjs.org/">SlimerJS</a> can both be used with this tool to capture images.</p>
</div>
<div class="paragraph">
<p>Personally I prefer using SlimerJS as their version of Gecko matches the latest Firefox. While PhantomJS Webkit is about a year behind Safari&#8217;s Webkit version. <code>SlimerJsVisualAcceptance</code> images come out much more accurate. Additionally, debugging the images produced from the <code>.ember-testing-container</code> in Firefox is useful. Since the <code>.ember-testing-container</code> is identical in SlimerJS and Firefox ( at least I&#8217;ve never seen a difference between the two).</p>
</div>
<div class="sect4">
<h5 id="_warning">Warning</h5>
<div class="paragraph">
<p>With certain repositories I&#8217;ve had trouble with SlimerJS having segmentation faults on both Linux and Mac. I&#8217;ve yet to resolve this issue.</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_html2canvas">Html2Canvas</h4>
<div class="paragraph">
<p>Html2Canvas is used when a browser does not have the function <code>window.callPhantom</code> (Only PhantomJS and SlimerJS have this defined). Html2Canvas is still in beta and as result you will see some issues.
Html2Canvas relies on Canvas drawing support. I find Chrome has the best Canvas drawing support (miles ahead of their competitors), while Firefox has the second best Canvas drawing support.</p>
</div>
<div class="sect4">
<h5 id="_svgs">SVGs</h5>
<div class="paragraph">
<p>Html2Canvas has difficulties rendering SVGs (more so in Firefox than in Chrome). As a result I have added a new <strong>expermental</strong> functionality that attempts to render the svgs better.
You can use this experimental feature by setting <code>experimentalSvgs</code> to <code>true</code> (Example: <code>capture('svg-experimental',{ experimentalSvgs: true})</code>).</p>
</div>
<div class="paragraph">
<p>Experimental SVGs will not be used for PhantomJS, SlimerJS, and Chrome/Chromium (Chrome properly renders svgs with html2canvas) as their rendering handles SVGs (PhantomJS and SlimerJS basically just take a screenshot of the page)</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_using_nightmare">Using Nightmare</h4>
<div class="listingblock">
<div class="title">Testem.json</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">{
  "framework": "mocha",
  "test_page": "tests/index.html?hidepassed",
  "disable_watching": true,
  "launch_in_ci": [
    "NightmareJsVisualAcceptance"
  ],
  "launch_in_dev": [
    "Firefox"
  ],
  "launchers": {
    "PhantomJsVisualAcceptance": {
      "command": "phantomjs vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    },
    "SlimerJsVisualAcceptance": {
      "command": "slimerjs -jsconsole vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    },
    "NightmareJsVisualAcceptance": {
      "command": "node vendor/nightmarejs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    }
  }
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_using_chromium">Using Chromium</h4>
<div class="paragraph">
<p>To use Chromium on Travis set</p>
</div>
<div class="listingblock">
<div class="title">Testem.json</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">  "launch_in_ci": [
    "Chromium"
  ],</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you&#8217;re using Mac OS X you&#8217;ll have to remove this when testing locally.</p>
</div>
</div>
<div class="sect3">
<h4 id="_using_firefox">Using Firefox</h4>
<div class="paragraph">
<p>To use Firefox on Travis simply set</p>
</div>
<div class="listingblock">
<div class="title">Testem.json</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">  "launch_in_ci": [
    "Firefox"
  ],</code></pre>
</div>
</div>
<div class="paragraph">
<p>And add the following to your <code>.travis.yml</code> to get the latest version of Firefox:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-yam" data-lang="yam">addons:
  firefox: "latest"</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_using_slimerjs">Using SlimerJS</h4>
<div class="listingblock">
<div class="title">Testem.json</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">{
  "framework": "mocha",
  "test_page": "tests/index.html?hidepassed",
  "disable_watching": true,
  "launch_in_ci": [
    "SlimerJsVisualAcceptance"
  ],
  "launch_in_dev": [
    "Firefox"
  ],
  "launchers": {
    "PhantomJsVisualAcceptance": {
      "command": "phantomjs vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    },
    "SlimerJsVisualAcceptance": {
      "command": "slimerjs -jsconsole vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    }
  }
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_using_phantomjs">Using PhantomJS</h4>
<div class="listingblock">
<div class="title">Testem.json</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">{
  "framework": "mocha",
  "test_page": "tests/index.html?hidepassed",
  "disable_watching": true,
  "launch_in_ci": [
    "PhantomJsVisualAcceptance"
  ],
  "launch_in_dev": [
    "Safari"
  ],
  "launchers": {
    "PhantomJsVisualAcceptance": {
      "command": "phantomjs vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    },
    "SlimerJsVisualAcceptance": {
      "command": "slimerjs -jsconsole vendor/phantomjs-launcher.js &lt;url&gt;",
      "protocol": "browser"
    }
  }
}</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_reports_for_multiple_browsers">Reports for  multiple browsers</h3>
<div class="paragraph">
<p>Producing a report for multiple browsers is perfectly fine. All you need to do is add your collection of browsers to <code>launch_in_ci</code>.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="title">Testem.json</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">"launch_in_ci": [
    "Firefox",
    "SlimerJsVisualAcceptance"
  ],</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="__code_timeout_of_2000ms_exceeded_code"><code>timeout of 2000ms exceeded</code></h3>
<div class="paragraph">
<p>With Travis you may find you see this error a few times. Sometimes Travis can take a while to run capture (especially if you&#8217;re using experimentalSvgs and have a lot of svgs on the page), and exceeds the timeout.</p>
</div>
<div class="paragraph">
<p>To resolve this simply increase the timeout by doing <code>this.timeout(5000)</code> in Mocha. I believe in Qunit you do <code>QUnit.config.testTimeout = 5000</code>.</p>
</div>
<div class="paragraph">
<p>In Mocha you can also set the timeout globally in <code>test-helper.js</code>:</p>
</div>
<div class="listingblock">
<div class="title">test-helper.js</div>
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">import resolver from './helpers/resolver'
import { setResolver } from 'ember-mocha'
import { mocha } from 'mocha'

mocha.setup({
  // customize as needed
  timeout: 5000
})
setResolver(resolver)</code></pre>
</div>
</div>
<div class="paragraph">
<p>In <code>describeComponent</code> there is no <code>this.timeout</code>. So you can set the timeout in the beforeEach fucntion by doing</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-javascript" data-lang="javascript">describeComponent(
  'frost-select',
  'Integration: FrostSelectComponent',
  {
    integration: true
  },
  function () {
    let props
    let dropDown
    beforeEach(function () {
      this.test._timeout = 6000
    })
    ...
})</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_notes">Notes</h4>
<div class="ulist">
<ul>
<li>
<p>Travis will upload the reports to Imgur</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If you would like to help or have ideas on improving this tool I&#8217;m available on the Ember community slack @ewhite613 - issues and PRs also welcome :)</p>
</div>
</div>
</div>
</div>
</div>]]></description><link>https://ciena-blueplanet.github.io/developers.blog/2016/07/18/Using-ember-cli-visual-acceptance.html</link><guid isPermaLink="true">https://ciena-blueplanet.github.io/developers.blog/2016/07/18/Using-ember-cli-visual-acceptance.html</guid><category><![CDATA[ember-cli-visual-acceptance]]></category><category><![CDATA[ Blog]]></category><category><![CDATA[ Open Source]]></category><category><![CDATA[ Visual Regression]]></category><dc:creator><![CDATA[Eric White]]></dc:creator><pubDate>Mon, 18 Jul 2016 00:00:00 GMT</pubDate></item></channel></rss>