-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
40 lines (37 loc) · 11.4 KB
/
index.html
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
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="alternative" href="/atom.xml" title="Zuker Blog" type="application/atom+xml"><link rel="icon" href="/favicon.png"><script>window.addEventListener('load', function(e) {
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
window.applicationCache.swapCache();
window.location.reload();
}
}, false);
}, false);
window.fbAsyncInit = function() {
FB.init({
appId: '323332107858531',
xfbml: true,
version: 'v2.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script><script src="https://apis.google.com/js/plusone.js" async defer type="text/javascript"></script><title>Zuker Blog</title><link rel="stylesheet" href="/css/main.css" type="text/css">
<!--[if lt IE 9]><script>(function(a,b){a="abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video".split(" ");for(b=a.length-1;b>=0;b--)document.createElement(a[b])})()</script><![endif]--></head><body><div id="fb-root"></div><header class="head"><h1 class="head-title u-fl"><a href="/">Zuker Blog</a></h1><nav class="head-nav u-fr"><ul class="head-nav__list"><li class="head-nav__item"><a href="/" class="head-nav__link">Home</a></li><li class="head-nav__item"><a href="/archives" class="head-nav__link">Archives</a></li></ul></nav></header><main class="main"><article class="post"><header class="post__head"><time datetime="2014-12-05T12:22:29.000Z" class="post__time">December 5, 2014</time><h1 class="post__title"><a href="/2014/12/05/Karmic-Challenge-Run-Tests-with-Karma-in-Bamboo-Agent/">Karmic Challenge: Run Tests With Karma in Internet Explorer on Bamboo Agent</a></h1></header><div class="post__main echo"><p>Recently I’ve finished work on small client-side JavaScript library, a simple REST API client, tests for this lib are running with <a href="http://karma-runner.github.io/" target="_blank" rel="external">Karma</a> and <a href="https://github.com/mochajs/mocha" target="_blank" rel="external">mocha</a>. I’m using Ubuntu on my laptop so it was not possible to run tests in IE during development, but luckily we have <a href="https://www.atlassian.com/software/bamboo" target="_blank" rel="external">Bamboo</a> as CI server in our company with build agents on Windows vm’s. So plan seemed to be plain and simple: create build job with “karma start” command and collect test reports.<br>But the real world has made its first adjustments. Dedicating Bamboo 5.6.0 build agent to build plan job doesn’t affects plan branches: if you’ve dedicated agent “Win” to job “Test” of plan “My App Build” with branch “dev” and launch “My App Build” branch dev it will be running on first free suitable agent and will not wait for agent “Win”. So I’ve had to dedicate agent to whole build plan.<br>Next problem was mysterious and unpredictable. When npm is running under Windows it is trying to use “%APPDATA%/npm” directory, on Windows 2012 Server with domain logon “%APPDATA%” for user “SYSTEM” (system services, including Bamboo agent, are running with this user by default) is “%SYSTEM%\config\systemprofile\AppData\Roaming\” but there was no “npm” dir and npm was crashing with “Error: ENOENT, stat ‘C:\Windows\config\system32\profile\AppData\Roaming\npm”. I’ve manually created this dir and… Surprise! The same “ENOENT” was here! WTF? I’ve tried to change permissions, owner, creating dir from user “SYSTEM” - nothing helped. I’ve leaved this mystery and changed logon user to “Administrator” for Bamboo agent service and “ENOENT” error gone.<br>It was victory? Not half! Running “npm install” directly from command prompt succeeded. However “npm install” build task failed with error</p>
<figure class="highlight [console]"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">npm <span class="built_in">ERR</span>! ws@<span class="number">0.4</span><span class="number">.32</span> install: `(node-gyp rebuild <span class="number">2</span>> builderror.<span class="built_in">log</span>) || (<span class="keyword">exit</span> <span class="number">0</span>)`</div><div class="line">npm <span class="built_in">ERR</span>! spawn ENOENT</div></pre></td></tr></table></figure>
<p>Brief googling led me to this <a href="https://github.com/npm/npm/issues/6300" target="_blank" rel="external">issue</a> after trying all suggested workarounds from comments spawn error was still there. So, remembering that all worked when running “npm install” manually, I’ve turned off Bamboo agent service and ran agent jar directly from Windows Task Scheduler as startup task. Packages install problem gone.<br>Finally build plan reached “karma start” task. Tests run in Firefox and Chrome was flawless, but some test cases in IE 10 were broken with error “This function is not supported on this system.” referencing to string 9 of <a href="http://sinonjs.org/" target="_blank" rel="external">sinon.js</a> “functionToString” function:</p>
<figure class="highlight [javascript]"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">sinon.functionToString = <span class="function"><span class="keyword">function</span> <span class="title">toString</span><span class="params">()</span> </span>{</div><div class="line"> <span class="keyword">if</span> (<span class="keyword">this</span>.getCall && <span class="keyword">this</span>.callCount) {</div><div class="line"> <span class="keyword">var</span> thisValue, prop, i = <span class="keyword">this</span>.callCount;</div><div class="line"></div><div class="line"> <span class="keyword">while</span> (i--) {</div><div class="line"> thisValue = <span class="keyword">this</span>.getCall(i).thisValue;</div><div class="line"></div><div class="line"> <span class="keyword">for</span> (prop <span class="keyword">in</span> thisValue) {</div><div class="line"> <span class="keyword">if</span> (thisValue[prop] === <span class="keyword">this</span>) {</div><div class="line"> <span class="keyword">return</span> prop;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">return</span> <span class="keyword">this</span>.displayName || <span class="string">"sinon fake"</span>;</div><div class="line">};</div></pre></td></tr></table></figure>
<p>Nothing criminal, a simple comparison. The only reason google gave me was IE 10 <a href="https://connect.microsoft.com/IE/feedback/details/794531/getting-an-exception-this-function-is-not-supported-on-this-system-when-using-localstorage-when-ie-started-under-the-windows-service" target="_blank" rel="external">bug</a> but I had already ran Bamboo agent as plain application, not service! Again, WTF? Update to IE 11 hasn’t helped. I was going to admit defeat and quarantine failing tests and forget all this challenge. And then I’ve noticed that all failing test cases are using <a href="http://sinonjs.org/" target="_blank" rel="external">sinon.js</a> spies and <a href="http://chaijs.com/" target="_blank" rel="external">chai</a> assertion plugin <a href="http://chaijs.com/plugins/sinon-chai" target="_blank" rel="external">sinon-chai</a> to check callback function calls, so I’ve made a final step in my “Karmic Challenge” - replaced all spies with plain callback: “asyncAction(spy)” -> “asyncAction(function () { done(); })”. It was all over and now I can sleep quietly.</p>
</div><footer class="post__foot u-cf"><div style="overflow: hidden;"><div data-href="http://zuker.github.io/2014/12/05/Karmic-Challenge-Run-Tests-with-Karma-in-Bamboo-Agent/" data-layout="button" style="float: left; padding: 10px" class="fb-share-button"></div><div style="float: left; padding-top: 11px; padding-left: 10px; padding-right: 10px; padding-bottom: 10px;"><a href="https://twitter.com/share" data-via="ZukerSFM" data-count="none" class="twitter-share-button">Tweet</a></div><div style="float: left; padding: 10px; width: 60px;"><div class="g-plusone"></div></div></div><ul class="post__tag u-fl"><li class="post__tag__item"><a href="/tags/bamboo/" class="post__tag__link">bamboo</a></li><li class="post__tag__item"><a href="/tags/ci/" class="post__tag__link">ci</a></li><li class="post__tag__item"><a href="/tags/karma/" class="post__tag__link">karma</a></li><li class="post__tag__item"><a href="/tags/node/" class="post__tag__link">node</a></li><li class="post__tag__item"><a href="/tags/ie/" class="post__tag__link">ie</a></li><li class="post__tag__item"><a href="/tags/windows/" class="post__tag__link">windows</a></li><li class="post__tag__item"><a href="/tags/sinon-js/" class="post__tag__link">sinon.js</a></li><li class="post__tag__item"><a href="/tags/chai/" class="post__tag__link">chai</a></li><li class="post__tag__item"><a href="/tags/mocha/" class="post__tag__link">mocha</a></li><li class="post__tag__item"><a href="/tags/tests/" class="post__tag__link">tests</a></li></ul><a href="/2014/12/05/Karmic-Challenge-Run-Tests-with-Karma-in-Bamboo-Agent/#disqus_thread" class="post__foot-link u-fr">0 COMMENTS</a></footer></article></main><footer class="foot"><div class="foot-copy u-fl">© 2014 Leonid Kuzmin</div><menu class="page-menu u-fr"><li class="page-menu__item"><span title="Previous" class="page-menu__link icon-arrow-left page-menu__link--disabled"></span></li><li class="page-menu__item"><span title="Next" class="page-menu__link icon-arrow-right page-menu__link--disabled"></span></li></menu></footer><script>(function(h,g,l,k,j,i){j=h.createElement(g),i=h.getElementsByTagName(g)[0],
j.src="//"+l+".disqus.com/"+k+".js",i.parentNode.insertBefore(j,i)})
(document,"script","zukerblog","count");
</script><script type="text/javascript">(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-57382089-1', 'auto');
ga('send', 'pageview');</script></body></html>