Giter Site home page Giter Site logo

karma-jasmine's Introduction

karma-jasmine

npm version npm downloads Release Workflow Status js-standard-style semantic-release

Adapter for the Jasmine testing framework.

Installation

npm install karma-jasmine --save-dev

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    files: [
      '*.js'
    ]
  })
}

If you want to run only some tests whose name match a given pattern you can do this in the following way

$ karma start &
$ karma run -- --grep=<pattern>

where pattern is either a string (e.g --grep=#slow runs tests containing "#slow") or a Regex (e.g --grep=/^(?!.*#slow).*$/ runs tests not containing "#slow").

You can also pass it to karma.config.js:

module.exports = function(config) {
  config.set({
    // ...
    client: {
      args: ['--grep', '<pattern>'],
      // ...
    }
  })
}

If you want to pass configuration options directly to jasmine you can do this in the following way

module.exports = function(config) {
  config.set({
    client: {
      jasmine: {
        random: true,
        seed: '4321',
        oneFailurePerSpec: true,
        failFast: true,
        timeoutInterval: 1000
      }
    }
  })
}

Debug by URL

Failing tests print a debug URL with ?spec=. Use it with --no_single_run and paste it into your browser to focus on a single failing test.

Sharding

By setting config.client.shardIndex and config.client.totalShards, you can run a subset of the full set of specs. Complete sharding support needs to be done in the process that calls karma, and would need to support test result integration across shards.

Custom spec filter

Providing a custom spec filter is also supported.

Example:

// Users are able to set a custom specFilter themselves

jasmine.getEnv().configure({
  specFilter: function (spec) {
    return spec.getFullName() === 'spec that succeeds'
  }
})

describe('spec', () => {
  it('that fails', () => {
    fail('This spec should not run!')
  })

  it('that succeeds', () => {
    expect(1).toBe(1)
  })
})

For more information on Karma see the homepage.

karma-jasmine's People

Contributors

commanderroot avatar dependabot[bot] avatar dignifiedquire avatar fadc80 avatar globin avatar jiverson avatar johnjbarton avatar kyliau avatar lalem001 avatar limonte avatar maksimr avatar milanlempera avatar mschaaf avatar nicojs avatar olegskl avatar r-park avatar readme42 avatar sahat avatar semantic-release-bot avatar sidvishnoi avatar strille avatar tailsu avatar tehvgg avatar toolmagic avatar twolfson avatar vavrecan avatar vojtajina avatar xhmikosr avatar yinm avatar zzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

karma-jasmine's Issues

No suites for `iit` tests

Let's consider this simple test:

describe('suite', function () {
    iit('spec', function () {
        expect(1).toBe(1);
    });
});

The problem is that onSpecComplete(browser, result) is called with empty result.suite.
As a result Jump To Source action (from right-click menu on a test tree node) in WebStorm Karma integration doesn't work.

Also ddescribe cuts upper suites:

describe('suite', function () {
    ddescribe('sub-suite', function () {
        it('spec', function () {
            expect(1).toBe(1);
        });
    });
});

Here onSpecComplete(browser, result) is called with result equals to

{
  description: 'spec',
  suites: ['sub-suite'],
  ...
}

NPM package 'latest' should point to '2.0'

I get the following when I check for outdated packages:

$npm outdated --depth=0
Package        Current  Wanted  Latest  Location
karma-jasmine    0.2.2   0.2.2   0.1.5  karma-jasmine

Latest should point to 0.2.2 instead of 0.1.5. And a dist-tag '1_0' could point to the old version instead.

No version match ~0.2.0 on npm registry

I just got following error when installing karma-jasmine

npm http GET http://registry.npmjs.org/karma-jasmine
npm http GET http://registry.npmjs.org/karma-jasmine
npm http GET http://registry.npmjs.org/karma-jasmine
npm ERR! notarget No compatible version found: karma-jasmine@'>=0.2.0-0 <0.3.0-0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.1.5","0.1.4","0.1.3","0.1.2","0.1.1","0.1.0","0.0.3","0.0.2","0.0.1"]

isSpecRunning() fails on TypeError: currentSpec.queue is undefined

This seems to occur if:

  1. you use karma-jasmine 0.2.1, which upgraded to Jasmine 2
  2. you call inject inside a spec function.
it('unfortunately throws a TypeError', function () {
   inject(function (aService) {
     // code...
   });
});
TypeError: Cannot read property 'running' of undefined
    at isSpecRunning (angular-mocks.js:1923:65)
    at window.inject.angular.mock.inject (angular-mocks.js:2087:12)
    ...

You can work around it by passing the result of inject directly to the it call.

it('works as expected', inject(function (aService) {
   // code...
}));

Failed test reporting

When using 2.* version, every failed test suite is reported as [object Object] instead of the suite's name. I narrowed the issue down to the karma jasmine adapter, as 1.* versions all work.

Example output, please notice the test suite name:

screen shot 2014-09-15 at 13 04 37

So, duplicate error messages

The drivers (and this may be a driver issue) working with Jasmine 1.X would result in concise assertion failure reports along the lines of:

PhantomJS 1.9.8 (Mac OS X) ngFromHtml() should work for simple dynamic html FAILED
        Expected '' to be '2'.
PhantomJS 1.9.8 (Mac OS X): Executed 4 of 4 (1 FAILED) (0.005 secs / 0.022 secs)

However, under Jasmine 2.x, we get duplicated errors messages:

PhantomJS 1.9.8 (Mac OS X) ngFromHtml() should work for simple dynamic html FAILED
        Expected '' to be '2'.
        Error: Expected '' to be '2'.
            at /Users/werdna/wiz-dev-env/test/environment.js:33
            at /Users/werdna/wiz-dev-env/node_modules/karma-jasmine/lib/boot.js:126
            at /Users/werdna/wiz-dev-env/node_modules/karma-jasmine/lib/adapter.js:171
            at http://localhost:9876/karma.js:189
            at http://localhost:9876/context.html:49

The latter yields overlong messages and lots of undesireable cruft.

Whaddya think? I'm happy to research this, but perhaps there is a simple and obvious solution my colleagues may provide?

Debug mode doesn't work in 0.3.5

I've updated karma-jasmine from 0.3.4 to 0.3.5 and I can no longer use the debug mode (I tested in Chrome and Firefox). The execution fails with the following errors:

Uncaught TypeError: Cannot read property 'args' of undefined - adapter.js:292
Uncaught TypeError: undefined is not a function - debug.html:35

The first error comes from this line:

return getGrepOption(config.args); // config is undefined

And the second one comes from here:

loaded: function() {
    this.start(); // this doesn't have a start method
}

I tracked down the first line to commit 4213b18, but I couldn't find the second one. I think it doesn't belong to karma-jasmine and it's a side effect of the first error.

FWIW, While I was reading the adapter.jsfile I noticed that there's a duplicate block of code:

/**
 * Extract grep option from karma config
 * @param {[Array|string]} clientArguments The karma client arguments
 * @return {string} The value of grep option by default empty string
 */
var getGrepOption = function(clientArguments) {
  var clientArgString = clientArguments || '';

  if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
    clientArgString = clientArguments.join('=');
  }

  var match = /--grep=(.*)/.exec(clientArgString);
  return match ? match[1] : '';
};

The same code appears again starting at line 255.

Jasmine__TopLevel__Suite in error message

In version 0.3 we have error message like this:

Jasmine__TopLevel__Suite Todo Controller having some saved Todos should count Todos correctly FAILED

String Jasmine__TopLevel_suite break Jump to source in WebStorm.

Error: 'null' is not an object (evaluating 'currentSpec.expect')

Hi
I'm using karma-jasmine v0.2.2.
When my test files become bigger and bigger I get the following error:

PhantomJS 1.9.7 (Mac OS X) ERROR  
TypeError: 'null' is not an object (evaluating 'currentSpec.expect')  
at /Users/kentarowakayama/CODE/ANGULAR/fischer/node_modules/karma-jasmine/lib/jasmine.js:698

Karma-jasmine errors on CentOS

When connecting to Karma get these errors:

Firefox 23.0.0 (Mac OS X 10.7) ERROR
    TypeError: window.parent.io.sockets[((location.protocol + "//") + location.host)] is undefined
    at /tmp/node_modules/karma-jasmine/lib/adapter.js:44
Chrome 29.0.1547 (Mac OS X 10.7.5) ERROR
    Uncaught TypeError: Cannot read property 'transport' of undefined
    at /tmp/node_modules/karma-jasmine/lib/adapter.js:44

Karma version:
0.10.2

Karma-jasmine version:
0.1.3

Node.js version:
v0.10.14

Os info:
Linux version 2.6.32-358.11.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) )

Error: browser is not defined

The test case throws the following error:

Chrome 29.0.1547 (Linux) Test test 1 FAILED
    ReferenceError: browser is not defined
        at null.<anonymous> (http://localhost:9876/base/test/test_index.html.js?1381331939000:6:9)
Chrome 29.0.1547 (Linux): Executed 1 of 1 (1 FAILED) ERROR (0.254 secs / 0.07 secs)

My karma config file is:

// Karma configuration
// Generated on Wed Oct 09 2013 17:04:44 GMT+0200 (CEST)

module.exports = function (config) {
    config.set({

        // base path, that will be used to resolve files and exclude
        basePath:'',


        // frameworks to use
        frameworks:['jasmine'],


        // list of files / patterns to load in the browser
        files:[
            'test/*.js'
        ],


        // list of files to exclude
        exclude:[

        ],


        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters:['progress'],


        // web server port
        port:9876,


        // enable / disable colors in the output (reporters and logs)
        colors:true,


        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel:config.LOG_INFO,


        // enable / disable watching file and executing tests whenever any file changes
        autoWatch:true,

        urlRoot:'/__karma/',
        proxies:{
            '/':'http://localhost:3000/'
        },


        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera
        // - Safari (only Mac)
        // - PhantomJS
        // - IE (only Windows)
        browsers:['Chrome'],


        // If browser does not capture in given timeout [ms], kill it
        captureTimeout:60000,


        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        singleRun:false


    });
};

My test case is:



describe('Test', function(){

    beforeEach(function(){
        browser().navigateTo('/index.html')
    })

    it('test 1', function(){

        console.log('doc',document)
        expect(true).toBe(true)
    })

})

Even if i move browser().navigateTo('/index.html') outside of beforeEach, nothing changes

npm package for karma-jasmine 0.2.1 can't be found

I was using the 0.2.1 package but today I can't seem to install it again:

npm http GET https://registry.npmjs.org/karma-jasmine
npm http GET https://registry.npmjs.org/karma-jasmine
npm http GET https://registry.npmjs.org/karma-jasmine
npm ERR! Error: No compatible version found: karma-jasmine@'>=0.2.0- <0.3.0-'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.1.0","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5"]
npm ERR!     at installTargetsError (/usr/local/Cellar/node/0.10.12/lib/node_modules/npm/lib/ca
che.js:719:10)
npm ERR!     at next (/usr/local/Cellar/node/0.10.12/lib/node_modules/npm/lib/cache.js:698:17)
npm ERR!     at /usr/local/Cellar/node/0.10.12/lib/node_modules/npm/lib/cache.js:678:5
npm ERR!     at saved (/usr/local/Cellar/node/0.10.12/lib/node_modules/npm/node_modules/npm-reg
istry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

Note none of the 0.2.x among the install targets. Was the package yanked for some reason?

beforeAll is undefined

beforeAll() and afterAll() are supported with Jasmine 2.1, but after installing the latest karma-jasmine (0.3.2) I got messages of them being undefined.

Adding the following to boot.js helped:

    beforeAll: function(beforeAllFunction) {
      return env.beforeAll(beforeAllFunction);
    },

    afterAll: function(afterAllFunction) {
      return env.afterAll(afterAllFunction);
    },

Support HTML error message output in formatFailedStep

Firstly thankyou for creating this usefull karma plugin, I've found it a great help with my work.

For a project I was working on I wanted to to use the imagediff framework for Jasmine to test some images.

I created an adapter that allowed me to do this with the karma-requirejs framework as my project used require.js, that adapter can be found here: karma-jasmine-imagediff.

When imagediff detects an error it outputs HTML showing the given, expected and diff images that you are testing as show here. This HTML output breaks karma-jasmine, specifically in function formatFailedStep in adapter.js:7 where stack.indexOf('\n') fails.

A quick fix for myself was to detect this and append step.message to the document.body if there was HTML output.

I think that there must be a better solution but I am not experienced enough with either jasmine or karma to issue a pull request.

Using the Jasmine UI with Karma

When using Jasmine outside of Karma, there's a built in web ui which gives a progress report of tests as well as lets users select features and individual tests to run.

Is this an option in karma-jasmine?

xdescribe causing timeouts

I am updated to these versions:

karma: 0.12.28
karma-jasmine: 0.3.2
jasmine-core: 2.1.3

and a few reporters/preporcessors. Haven't had issues until upgrading from:

karma: 0.12.22
karma-jasmine: 0.2.2

It seems to get stuck on xdescribes no matter how long the timeout period is.

Let me know if you need more information!

Mocking the JavaScript Timeout Functions in IE 8 with Jasmine 2.0.0

Hi

I'm having issues using Jasmines clock mock with Karma.
I have reported the issue to Jasmine here but since the issue is only present with Karma I report it here instead.

The following test does not work with Karma in IE 8.

describe('Clock', function() {
    beforeEach(function() {
        jasmine.clock().install();
    });

    afterEach(function() {
        jasmine.clock().uninstall();
    });

    it('works in IE 8', function() {
        var test = jasmine.createSpy('timeout');
        setTimeout(test, 1000);
        jasmine.clock().tick(1000);
        expect(test).toHaveBeenCalled();
    });
});

It works with Jasmines SpecRunner.html.

I have done some experimenting and I can break Jasmines clock mock in IE 8 by calling setTimeout() before the first use of the mock.

Install from fork, problems with adapter.js

Hi,

I've forked karma-jasmine, and have some problems installing it directly from github. I've included my fork like this in my package.json of a test project:

"karma-jasmine": "git://github.com/23tux/karma-jasmine.git#prettyPrint"

The problem is, that the adapter.js isn't created. I've seen, that this file is generated with a grunt build call inside karma-jasmine. I've played around with

  "scripts": {
    "test": "grunt test",
    "postinstall": "./grunt build"
  },

inside the package.json from karma-jasmine, but with no luck.

So, can someone tell me what the guidelines for contribution are? Do you compile the adapter.js manually and add it to the npm package? Or is there any way around, to install it directly from a github source?

Update Jasmine to v2.0.2

During these two minor releases, the possibility to mock Date() has been reinserted to Jasmine.

Tests start executing before page is loaded

I am using karma-jasmine: 0.3.5. I have tests that run perfectly from a HTML runner that loads jasmine 2.2 but when I run them through karma using karma-jasmine they fail. I have investigated the problem and it seems that the tests start executing before the DOM is ready (which is not the case when run from a HTML runner). After updating the createStartFn function in the adapter.js file to the code below which waits for the DOM ready the tests started passsing.

function createStartFn(karma, jasmineEnv) {
  // This function will be assigned to `window.__karma__.start`:
  return function () {
    $(function () {
      jasmineEnv = jasmineEnv || window.jasmine.getEnv();

      jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv));
      jasmineEnv.execute();
    });
  };
}

More intuitive combination of ddescribe and iit needed for test suite factories

There should be a way to force running a test not by simply checking whether it's defined with iit (as it is now) but also by scoring each ocurrentce of iit and only running those with the highest score:

ddescribe('Module: foo (to run tests only for this very module)', function () {
    ddescribe('Service: foo to run tests only for this service', function () {
        iit('should run because it is forced');
    });

    describe('Service: bar', function () {
        iit('Now runs because it is forced. I suggest it should not run because it has less ddescribes on the "way" to this iit then the first one in this snippet.');
    });
})

The same expressed using the suite factory:

ddescribe('Module: foo (to run tests only for this very module)', function () {

    function mySuiteFactory(data) {
        return function () {
            iit('should run because it is forced And now it runs 2 times - for both describes', function () {
                // use the `data` given to the factory.
            });
            // I suggest running the test above only when it's top scored.
        }
    }
    ddescribe('Service: foo to run tests only for this service', mySuiteFactory(data1));
    describe('Service: bar (where the test should not run despite the fact it is forced)', mySuiteFactory(data2));
})

Real life example:
I have a simple service that is responsible for converting different forms of an expression with the same meaning. I have 5 ways to express the same thing: 4 of them are strings and the 5th is a collection of object. Each way (or as I call it: a variant) is used in different circumstances but all of them are capable of expressing the same logic.

I built a factory that returns the suite of cases that cover all the conversions. A fixture with the same thing expressed in 5 variants is the argument of the factory. Result of calling this factory may be passed as the 2nd argument of describe:

function getCrossTestsFor(data) {
    return function () {
        let converter;
        beforeEach(inject(function (converterService) {
            converter = converterService;
        }));
        it('should get converted from `variant1` to `variant2`', function () {
            expect(converter.variant1.toVariant2(data.variant1)).toBe(data.variant2);
        });
        // And 19 more "its": 5 variants = 5*(5-1) "its" 
    }
}

The same may be expressed without returning wrapped in an anonymous function but this way it can be passed as the 2nd argument of describe right away.

Then I define a suite like this:

describe('value `undefined`', getCrossTestsFor({
    variant1: undefined,
    variant2: undefined,
    variant3: undefined,
    variant4: undefined,
    variant5: undefined,
}));

describe('value "empty string"', getCrossTestsFor({
    variant1: '',
    variant2: '',
    variant3: '',
    variant4: '',
    variant5: [],
}));

And I have many such sub-suites (all in all: n*20 tests).

When something breaks I get many errors due to the nature of how the the suite is defined: When something breaks it affects more than one it either because of the error in decoding a variant or in encoding the decoded data back to some other.
I have meaningful error messages like this:

FAIL: value "empty string" should get converted from `variant1` to `variant2`

But I cannot run only this single test.

I tend to fix tests one by one by forcing only one to run. I don't know if it's a good practice generally but it's a good one in my case ;) I do this by forcing certain suites or certain tests. But it's not possible in this case, when suite factory pattern is used.

I also tried to define its in loops but though it seems to be a cleaner way to test large portions of data It came out that this pattern is far more difficult to debug: Not only I have to force the it in loop (or loopsas it was in my case) but I also have to make sure the loop (or each of the loops) is run only once to run a single test. Effectively I have to comment out large portions of my data fixture apart from of just using the jasmine-karma feature of forcing a test or a suite (iit, ddescribe).

Back to the topic: Putting ddescribe before any suite results in running "only" 20 of my tests. Some of them are broken, some are not.
Putting iit before one of the tests that fail results in running n tests (not one!). This is because in fact this iited test is present in n describes (see the abstract example at the beginning).

I found the way to extract only one of my (n*20) tests and focus on fixing this one: I force (ddescribe) the suite that fails but instead of iiting the failing test one I exclude (xit) all the others.
Only this combination results in running the particular test that I want to focus on. But the procedure is laborious.

I wonder if it might be simplified.

__karm__.start method missing?

Running the latest karma-jasmine, I'm noticing this error. Looking at the code there is no adapter.js file within the lib directory. I tried manually setting it to read the src/adapter.js file, but it only got rid of the warning and I still encountered the __karma__.start method! error.

INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
WARN [watcher]: Pattern "/Users/chesleybrown/Sites/bln-web/node_modules/karma-jasmine/lib/adapter.js" does not match any file.
INFO [PhantomJS 1.9.8 (Mac OS X)]: Connected on socket Ye-LnkBcsCrVxrp6yzO- with id 91682340
PhantomJS 1.9.8 (Mac OS X) ERROR
  You need to include some adapter that implements __karma__.start method!

Karma runner/Jasmine 2.0

Hello, hopefully this is the right place to post. I was wondering when Jasmine 2.0 will be available with karma (karma-jasmine). I like how jasmine tests async functions in 2.0, but currently there is no way for me to use Jasmine 2.0 (or is there?).

Thank you!

Peer [email protected] wants karma@~0.9

npm ERR! peerinvalid Peer [email protected] wants karma@~0.9, but current version is v0.8.7 (2013-07-18)

Running the common command
sudo npm -g install grunt-cli karma bower
produces the following errors:

Debug Log: https://docs.google.com/file/d/0BwV7xb-E6LSNU2MwN0ZnakxwMmc/edit?usp=sharing

> [email protected] install /usr/local/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/bufferutil.node
  SOLINK_MODULE(target) Release/bufferutil.node: Finished
  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/validation.node
  SOLINK_MODULE(target) Release/validation.node: Finished
/usr/local/bin/karma -> /usr/local/lib/node_modules/karma/bin/karma
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/couch-login requires request@'~2.9.202' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/request,
npm WARN unmet dependency which is version 2.21.0
npm ERR! peerinvalid The package karma does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants karma@~0.9

npm ERR! System Darwin 11.4.2
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "-g" "install" "grunt-cli" "karma" "bower"
npm ERR! cwd /Users/per/Workspace/ng-boilerplate
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! code EPEERINVALID
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/per/Workspace/ng-boilerplate/npm-debug.log
npm ERR! not ok code 0

Karma-jasmine: How to work with JSON files from Karma, i am receiving a TypeError

Hi all,
When i run my Karma i am receiving an issue "TypeError: Cannot read property 'description' of undefined" and i think is due the JSON files are not loading properly when i run Karma.

Here you are same screemshots:
1 - I have an spec file that is loading JSON files:
spec

json

2- My Karma file:
karma

3 - My pakage json
pakage json

Do you know how to kix that issue?

Regards
Javi

Regression: no ddescribe/iit

karma-jasmine 0.3.3 and 0.3.4 doesn't support ddescribe and iit. karma-jasmine 0.3.2 does. Looking at the commit queue, the lib/boot.js file has been completele reorganized between 0.3.2 & 0.3.3, changing API in the process (207018b). Such things shouldn't happen in a patch release, it's a breaking change.

0.3.3 should really be 0.4.0. Could you release 0.3.5 that is a re-release of 0.3.2 and bump 0.3.4 master to 0.4.0? Otherwise people that include "karma-jasmine": "~0.3.2" may now have their builds broken.

Uncaught TypeError: Cannot read property 'transport' of undefined adapter.js:44:76

Using karma start karma.conf.js in console.
Launches Chrome
Click Debug
Opens http://localhost:8082/debug.html
Open Dev Tools Console

Uncaught TypeError: Cannot read property 'transport' of undefined adapter.js:44

I get the same error debugging my test from IntelliJ IDEA, which includes the following stack trace:

Uncaught TypeError: Cannot read property 'transport' of undefined   adapter.js:44:76
  getCurrentTransport   adapter.js:44:76
  reportRunnerStarting  adapter.js:84:21
  (anonymous function)  jasmine.js:1869:39
  jasmine.Runner.execute    jasmine.js:2222:23
  jasmine.Env.execute   jasmine.js:864:23
  (anonymous function)  adapter.js:158:16
  window.__karma__.loaded   debug.html:17:14
  (anonymous function)  debug.html:2:22

Use Jasmine from NPM

Is there any reason why Jasmine is bundled with karma-jasmine instead of listed as a dependency? This caused me some trouble when debugging…

migration from 0.1.5 to 0.2.2

this.addMatchers({
    toEqualData: function(expected) {
        return angular.equals(this.actual, expected);
    }
});

The code above no longer works

TypeError: Object #<Object> has no method 'addMatchers' at Object.<anonymous> (/home/deyine/workspace/my-project/test/spec/modules/contact/controllers.js:7:10)

Uncaught TypeError: Cannot read property 'host' of undefined on OSX 10.9.1 with any test Runner

On a fresh install of brew, node, npm, karma and Chrome under OSX 10.9.1, I'm repeatedly seeing this error:

Chrome 31.0.1650 (Mac OS X 10.9.1) ERROR
    Uncaught TypeError: Cannot read property 'host' of undefined
    at /usr/local/lib/node_modules/karma-jasmine/lib/adapter.js:40
Chrome 31.0.1650 (Mac OS X 10.9.1): Executed 0 of 0 ERROR (0.854 secs / 0 secs)

Bizarrely I could reproduce this issue when using PhantomJS and Firefox as the clients as well. I'm thoroughly confused. When inspecting in Chrome it looks like line 40 of adapter.js is:

var parentWindow = window.opener || window.parent;

Chrome claims parentWindow is just a plain Object, not a Window object and returns:

> parentWindow
   Object {}
> parentWindow.location
   undefined

which is clearly the source of the error, but I have no idea why. Attempting to reproduce this error on another computer has proven futile.

ERROR [karma]: [TypeError: Cannot read property * of undefined]

I have the same issue but running karma directly from Node.js, when i run my "grunt test:unit", i am receiving the following error:
nodejs

My Karma config file:
karma

Unit test code:
code

Any idea how to fix that and run my UI Unit test with Karma? thanks alot for your help!!!!

ERROR [karma]: [TypeError: Cannot read property * of undefined]

I am using WebStorm combined with karma to run Jasmine javaScript unit tests. If I have nested describe statements then karma is crashing, or maybe it's WebStorm crashing, I'm not sure.

The karma error output says:

ERROR [karma]: [TypeError: Cannot read property 'should return a Foo' of undefined]

Any idea where the problem might be?

Code is found in my question here:

http://stackoverflow.com/questions/20458547/why-is-karma-or-webstorm-crashing-when-using-nested-describe-statements-in-a-jas

Multi-line error messages are rendered in a weird order

Try this:

expect('Hello\nWorld').toBe(0);

The displayed error message is:

FAILED TESTS:
  myTest
    myOtherTest
      ✖ should work
        PhantomJS 1.9.8 (Mac OS X)
      World' to be 0.
      Error: Expected 'Hello
          at /var/folders/(...)/blablabla-test.js:126:0

The problem is that in the function getRelevantStackFrom(stack) the stack is splitted by \nand when the stack also contains the error message the output is formatted wrong in the function formatFailedStep(step)

new to jasmine and getting this error:

ReferenceError: browser is not defined in http://localhost:51328

here is my code:

describe('SDJS Navigation Scenarios', function() {
beforeEach(function() {
browser().navigateTo('../../index.html');
});

// Navigation Tests - BEGIN
it('main navigation options', function() {
    expect(element('[ng-controller] ul li a').text()).toMatch(Home);
    expect(element('[ng-controller] ul li a').text()).toMatch(Design);
    expect(element('[ng-controller] ul li a').text()).toMatch(Insert);
    expect(element('[ng-controller] ul li a').text()).toMatch(Page);
    expect(element('[ng-controller] ul li a').text()).toMatch(Review);
    expect(element('[ng-controller] ul li a').text()).toMatch(Help);
});

});

--any suggestions...thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.