I am here to ask for some help because I can't reach a solution and I have spent so much time on this.
The problem is a weird behavior in karma + jasmine tests, initially I thought that the problem was in AngularJs code but, stripping down by stripping down I reached the point where there is nothing else to remove and the problem is 100% not in angular.
The actual code that I am using is this:
test.js:
'use strict';
describe('Unit tests suite', function () {
it('test', function () {
expect('base').toEqual('');
});
});
karma.conf.js:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: ['*.js'],
exclude: [],
preprocessors: {},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
})
}
Absolutely nothing else. The result of that test is:
13 02 2016 04:32:39.559:WARN [karma]: No captured browser, open http://localhost:9876/
13 02 2016 04:32:39.571:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
13 02 2016 04:32:39.578:INFO [launcher]: Starting browser PhantomJS
13 02 2016 04:32:41.248:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket HiC4WW_4235Nlf0rAAAA with id 54292207
PhantomJS 2.1.1 (Mac OS X 0.0.0) Unit tests suite test FAILED
Expected '/Users/Gianmarco/Desktop/test' to equal ''.
/Users/Gianmarco/Desktop/test/test.js:5:31
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.003 secs / 0.003 secs)
As you can see it seems that the word "base" is being changed with the path of the folder. This is making me going nuts I can't figure out why it is doing so.
I tried both with MacOSX and Ubuntu 14.04 and the result is the same.
To prepare the folder I did this:
mkdir test
cd test
npm install jasmine-core karma-cli karma-jasmine karma-phantomjs-launcher phantomjs-prebuilt --save
karma init
karma start
and of course my system had a npm install karma-cli -g
some time ago.
The versions are:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
The same behaviour is obtained using the word absolute, that is replaced with an empty string
I believe its a problem with the default reporter in karma (progress) it appears the URL_REGEX matches both base and absolute as all the rest of the regex is optional.
var URL_REGEXP = new RegExp('(?:https?:\\/\\/[^\\/]*)?\\/?' +
'(base|absolute)' + // prefix
'((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path
'(\\?\\w*)?' + // sha
'(\\:(\\d+))?' + // line
'(\\:(\\d+))?' + // column
'', 'g')
https://github.com/karma-runner/karma/blob/684ab1838c6ad7127df2f1785c1f56520298cd6b/lib/reporter.js#L25
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With