Visual Studio Team Services and Karma - visual-studio

Any idea how you can run Karma unit tests inside VSTS? Do they have to be integrated with the Visual Studio Test Runner or is there a better way?
The project is purely client-side static SPA website so it has no Visual Studio solution or project.
Also It seems like even when I try to run Karma via NPM it seems like PhantomJS refuses to start on the Agent.
Logs from the Build:
2016-08-03T02:45:44.9647601Z webpack: bundle is now VALID.
2016-08-03T02:45:44.9717626Z [32m03 08 2016 02:45:44.968:INFO [karma]: [39mKarma v0.13.22 server started at http://localhost:9876/
2016-08-03T02:45:44.9767811Z [32m03 08 2016 02:45:44.976:INFO [launcher]: [39mStarting browser PhantomJS
2016-08-03T02:46:44.9784272Z [33m03 08 2016 02:46:44.977:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms, killing.
2016-08-03T02:46:46.9783856Z [33m03 08 2016 02:46:46.977:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms, sending SIGKILL.
2016-08-03T02:46:48.9792421Z [33m03 08 2016 02:46:48.978:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms, continuing.
2016-08-03T02:46:49.1602394Z npm ERR! Test failed. See above for more details.
2016-08-03T02:46:49.1722407Z ##[debug]rc:1
2016-08-03T02:46:49.1722407Z ##[debug]success:false
2016-08-03T02:46:49.1722407Z ##[debug]taskRunner fail
2016-08-03T02:46:49.1732408Z ##[debug]task result: Failed
2016-08-03T02:46:49.1782402Z ##[error]Npm failed with error: C:\Program Files\nodejs\npm.cmd failed with return code: 1
2016-08-03T02:46:49.1962405Z Finishing task: Npm
2016-08-03T02:46:49.2032405Z ##[error]System.Exception: Task Npm failed. This caused the job to fail. Look at the logs for the task for more details.
2016-08-03T02:46:49.2042402Z ##[error] at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource)

I'm not sure what is your configuration of steps, but it's works perfectly fine on my build definition.
Check also capabilities of your agent, should have node.js and npm capability.

Related

Jenkins - jmeter performance plugin - Build step 'Publish Performance test result report' changed build result to FAILURE Finished: FAILURE

I m trying to generate performance report through jenkins peformance plug-in, when ever i try to perform build now. i get the error
- Started by user Mukesh kumar
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Aug17- Jmeter test
[Aug17- Jmeter test] $ cmd /c call C:\windows\TEMP\jenkins2034852437917248179.bat
C:\Program Files (x86)\Jenkins\workspace\Aug17- Jmeter test>C:\Users\ux010725\Downloads\Softwares\Jmeter\apache-jmeter-4.0\bin\jmeter.bat -Jjmeter.save.saveservice.output_format=xml -n -t C:\Users\ux010725\Downloads\Softwares\Jmeter\apache-jmeter-4.0\TestPlan_Aug14.jmx -l Mukesh_Reports\r2.xml
Creating summariser <summary>
Created the tree successfully using C:\Users\ux010725\Downloads\Softwares\Jmeter\apache-jmeter-4.0\TestPlan_Aug14.jmx
Starting the test # Fri Aug 17 15:48:37 IST 2018 (1534501117309)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary = 42 in 00:00:09 = 4.6/s Avg: 208 Min: 113 Max: 2358 Err: 0 (0.00%)
Tidying up ... # Fri Aug 17 15:48:47 IST 2018 (1534501127021)
... end of run
Cannot detect file type because of error: Failed to copy C:\Users\ux010725\Downloads\Softwares\Jmeter\apache-jmeter-4.0\bin\Mukesh_Reports\r2.xml to C:\Program Files (x86)\Jenkins\jobs\Aug17- Jmeter test\builds\17\temp\r2.xml
Build step 'Publish Performance test result report' changed build result to FAILURE
Finished: FAILURE
Try removing spaces in « Aug17- jmeter test »
This might explain the failure

Wallaby.js hangs during initalization

I'm trying to get Wallaby.js running on my solution in VS2013 and I'm getting some weird behaviour.
If it is running and I change the config file I have to stop it. It errors with the following message
wallaby.js started core v1.0.159 Failed to start stop operation,
Error: ENOENT: no such file or directory, unlink
'C:\Users\XXXX\AppData\Local\Temp\1.wallaby\projects\FG57vVlzA+WewEWCpi1WInb+g1k=\cache\instrumented\somepath\somefile.ts.compiled.js'
at Error (native) at Object.fs.unlinkSync
(evalmachine.:931:18) at EventEmitter.u.unlinkFileSync
[as _unlinkFileSync] (C:\Users\XXXX.wallaby\core\server.js:18:11095)
at C:\Users\XXXX.wallaby\core\server.js:16:6022 at baseFor
(C:\Users\XXXX.wallaby\core\node_modules\lodash\index.js:1971:13)
at baseForOwn
(C:\Users\XXXX.wallaby\core\node_modules\lodash\index.js:2025:14)
at baseEach
(C:\Users\XXXX.wallaby\core\node_modules\lodash\index.js:1814:16)
at Function.forEach
(C:\Users\XXXX.wallaby\core\node_modules\lodash\index.js:5701:11)
at EventEmitter._.extend.stop
(C:\Users\XXXX.wallaby\core\server.js:16:5651) at Object.i.receive
(C:\Users\XXXX.wallaby\core\server.js:14:1177) at
WebSocket. (C:\Users\XXXX.wallaby\core\server.js:18:12016)
at emitTwo (events.js:87:13) at WebSocket.emit (events.js:169:7)
at Receiver.self._receiver.ontext
(C:\Users\XXXX.wallaby\core\node_modules\ws\lib\WebSocket.js:682:10)
at Receiver.opcodes.1.finish
(C:\Users\XXXX.wallaby\core\node_modules\ws\lib\Receiver.js:391:14)
at Receiver.expectHandler
(C:\Users\XXXX.wallaby\core\node_modules\ws\lib\Receiver.js:372:33)
at Receiver.add
(C:\Users\XXXX.wallaby\core\node_modules\ws\lib\Receiver.js:87:24)
at Socket.firstHandler
(C:\Users\XXXX.wallaby\core\node_modules\ws\lib\WebSocket.js:663:22)
at emitOne (events.js:77:13) at Socket.emit (events.js:166:7) at
readableAddChunk (_stream_readable.js:146:16) at
Socket.Readable.push (_stream_readable.js:109:10) at TCP.onread
(net.js:517:20)
wallaby.js stopped
Then I start Wallaby.js and it hangs on the initialization stage, as indicated in the bottom left corner of VS2013
Wallaby.js: Initializing runner
and the console output never moves past
wallaby.js started
core v1.0.159
I then stop Wallaby.js and nothing happens.
I then stop Wallaby.js and the console reports Wallaby.js has stopped (The context menu for my config file show stop, restart, and start cmd's)
wallaby.js started
core v1.0.159
wallaby.js stopped
Then I start Wallaby.js again, and it works...
I followed the steps outline for installing Wallaby.js and have been fumbling my way through the configuration doco. Any help on this would be appreciated.
It is most certainly the result of leading ./ in your files/tests paths/patterns in your wallaby config. Please remove t and try again.

Karma + Xvfb + Firefox does not work anymore

I've got a problem with my CI setup.
Since a couple of days Firefox doesn't run our Jasmine tests with Karma anymore.
But Chrome does - so the error should not depend on the tests themselves.
On my development environment it runs as well.
I did not change anything on the CI-server (Ubuntu).
What happens:
Firefox is connecting to the web-server and establishes a session.
But the tests are not executed.
What I already tried:
I already changed the timeout.
I already restarted the machine (a couple of times).
And I already reinstalled firefox.
Do you have an idea, what causes this strange behaviour or how I can debug this?
We are using
karma#0.12.37
karma-jasmine#0.3.5
karma-firefox-launcher#0.1.6
Firefox v.38.0
Ubuntu
nodejs v.0.10.25
npm v 1.3.10
Xvfb
karma.conf.js
module.exports = function(config) {
config.set({
browserNoActivityTimeout: 100000,
basePath: 'src/main/webapp/',
singleRun: true,
// autoWatch: true,
logLevel: config.LOG_DEBUG,
files: [
'assets/libs/jquery/dist/jquery.min.js',
'assets/libs/angular/angular.min.js',
'assets/libs/angular-mocks/angular-mocks.js',
'assets/libs/**/*.min.js',
'app/app.js',
'app/**/*.js',
'app/directives/*/*.html',
'app/directives/*/*.js',
'../../test/frontend/**/*.js', {
pattern: 'assets/libs/**/*.map',
included: false
},
'app/views/*.html'
],
preprocessors: {
'app/views/*.html': 'ng-html2js',
'app/directives/*/*.html': 'ng-html2js'
},
frameworks: ['jasmine'],
browsers: [
'Firefox'
],
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-safari-launcher',
'karma-ie-launcher',
'karma-jasmine',
'karma-junit-reporter',
'karma-ng-html2js-preprocessor'
],
reporters: ['progress', 'junit'],
junitReporter: {
outputFile: '../../../build/test-results/karma-test-results.xml'
},
ngHtml2JsPreprocessor: {
moduleName: 'myc-templates'
}
});
};
Output of 'xvfb-run karma start'
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser Firefox
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-70931573
DEBUG [launcher]: firefox http://localhost:9876/?id=70931573 -profile /tmp/karma-70931573 -no-remote
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/karma.js
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/favicon.ico
DEBUG [web-server]: upgrade /socket.io/1/websocket/5wtT2gW7_XuaTRZ3Gctt
DEBUG [karma]: A browser has connected on socket 5wtT2gW7_XuaTRZ3Gctt
INFO [Firefox 38.0.0 (Ubuntu 0.0.0)]: Connected on socket 5wtT2gW7_XuaTRZ3Gctt with id 70931573
DEBUG [launcher]: Firefox (id 70931573) captured in 3.542 secs
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/context.html
DEBUG [Firefox 38.0.0 (Ubuntu 0.0.0)]: Disconnected during run, waiting 2000ms for reconnecting.
WARN [Firefox 38.0.0 (Ubuntu 0.0.0)]: Disconnected (1 times)
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [reporter.junit]: JUnit results written to "/var/lib/jenkins/jobs/MYC/workspace/build/test-results/karma-test-results.xml".
DEBUG [launcher]: Process Firefox exited with code 0
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-70931573
npm ERR! weird error 1
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
Any tipps or ideas how to solve this are very much appreciated ;-)
Thanks, Sebastian

grunt "Error: Cannot find module '../time/convert' (only on windows)

Setup a new angular project under linux. Committed it to git and cloned it to windows. Using bower and npm, I managed to get everything loaded, except, I have this one error (only on windows)
A recursive grep for ../time/convert in the project shows me:
./node_modules/grunt-contrib-imagemin/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/mout/date/diff.js:var convert = require('../time/convert');
./node_modules/grunt-contrib-imagemin/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/mout/src/date/diff.js:define(['./totalDaysInMonth', './totalDaysInYear', '../time/convert'], function(totalDaysInMonth, totalDaysInYear, convert){
./node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/bin-wrapper/node_modules/mout/date/diff.js:var convert = require('../time/convert');
./node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/mout/date/diff.js:var convert = require('../time/convert');
./node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/mout/src/date/diff.js:define(['./totalDaysInMonth', './totalDaysInYear', '../time/conve
but ls -l shows:
$ ls ./node_modules/grunt-contrib-imagemin/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/mout/time
convert.js now.js parseMs.js toTimeString.js
Which says that convert.js is actually there. Being new to grunt and angular, I'm puzzled where this could be coming from and how to troubleshoot it.
After this I end up getting stuck here:
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.4 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern ".../test/mock/**/*.js" does not match any file
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start Chrome again.
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start Chrome again.
Wondering if angular work using grunt is just not possible on Windows....
My solution was to quit using windows. Moved dev work to linux, and no more crazy problems like this. Oh, and my machine now seems a good deal faster too.

phantomjs does not capture

I set up a standard yeoman/angular installation on Mac OS X 10.8.3 using npm. I created a new angular project using the yo generator. I installed phantomjs via npm install -g phantomjs. I configured karma to unly use phantomjs (all other browsers work fine). When running tests with grunt test, phantomjs does not capture at all, even if I set a very long timeout (50000ms). This is the log output:
Running "karma:unit" (karma) task
DEBUG [reporter]: Using reporter "progress".
INFO [karma]: Karma server started at http://localhost:8080/
INFO [launcher]: Starting browser PhantomJS
DEBUG [launcher]: Creating temp dir at /var/folders/6j/gz50dm2d3xv1hnz7s1t4lhn40000gp/T/testacular-79891032
DEBUG [launcher]: /usr/local/bin/phantomjs /var/folders/6j/gz50dm2d3xv1hnz7s1t4lhn40000gp/T/testacular-79891032/capture.js
WARN [watcher]: Pattern "/Users/alexanderwalter/Development/angularSeed/test/mock/**/*.js" does not match any file.
DEBUG [watcher]: Resolved files:
/Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/adapter/lib/jasmine.js
/Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/adapter/jasmine.js
/Users/alexanderwalter/Development/angularSeed/app/components/angular/angular.js
/Users/alexanderwalter/Development/angularSeed/app/components/angular-mocks/angular-mocks.js
/Users/alexanderwalter/Development/angularSeed/app/scripts/app.js
/Users/alexanderwalter/Development/angularSeed/app/scripts/controllers/add.js
/Users/alexanderwalter/Development/angularSeed/app/scripts/controllers/main.js
/Users/alexanderwalter/Development/angularSeed/test/spec/controllers/add.js
/Users/alexanderwalter/Development/angularSeed/test/spec/controllers/main.js
DEBUG [web server]: serving: /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/static/client.html
DEBUG [web server]: serving: /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/static/testacular.js
DEBUG [karma]: New browser has connected on socket wxBffi5IEZn9zQvoTm0J
WARN [launcher]: PhantomJS have not captured in 50000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 1
ERROR [launcher]: Cannot start PhantomJS
As I said, it works for all other browsers. Phantomjs also works if I pass it a simple test script which prints hello world to the console.
I had the same issue and found out it was a problem with nodejs 0.10.8/0.10.9: https://github.com/karma-runner/karma/issues/558
Downgrading to nodejs 0.10.7 solved the problem for me.
In case you want to go with node 0.10.11, the Proxy option worked for me (Mac 10.6.8, Karma 0.8.5, and node 0.10.11 or 0.10.7. Node 0.10.8/9/10 didn't work.).
Inside the karma.conf.js file:
proxies = {
'/': 'http://localhost:9000'
};
urlRoot = '/__unit/';
Inside the karma-e2e.conf.js file:
proxies = {
'/': 'http://localhost:9000'
};
urlRoot = '/__e2e/';
I upgraded to the latest stable version of Node.js. This solved it for me. currently v.10.20.

Resources