8

I can run Jasmine unit tests from the Resharper 8.0 unit test runner. I have a problem where any Javascript references that are normally in the html page (ie in my case Ext-Js) then I can't use the Resharper test runner, as you don't seem to have access to the HTML page that Resharper uses. (I assume it's generated as I could not locate it on disk)

I was thinking if there is a way to call or load your external library references from the Javascript test file directly instead of via the html page, then I could get this to work. I've not found if that is possible with Javascript (or Ext-Js) yet.

Stephen Price
  • 1,629
  • 1
  • 24
  • 42

2 Answers2

12

It seems the way to go at the moment is hardcoding include statements as special comments in the suite file (called doc-comments references), e.g.:

// include external files like so:
/// <reference path="/path/to/external-file.js" />

// than write your testing suite as usual:
describe('a silly suite', function() {
    it('should test something is happening', function() {
        expect(something).toBe('happening');
    });
});

See this thread on the ReSharper community, as the source of this recommendation.

Eliran Malka
  • 15,821
  • 6
  • 77
  • 100
  • I saved the file locally in the project (was an external referenced file) and it worked. Is there a way to reference external files? ie path="http://server/ext-all-debug.js" – Stephen Price Jul 29 '13 at 07:37
  • If by *external files* you mean files residing on another domain, e.g. `http://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css`, I suspect it would work the same way. give it a go and let me know if that worked. – Eliran Malka Jul 30 '13 at 18:15
  • Tried that, apparently the reference documentation only supports local files relative to the same domain. ie external files don't work. I think that's where I had my initial issues getting it to work. Copying the remote file to a local one worked as advertised. – Stephen Price Jul 31 '13 at 02:24
0

I wrote 2 repos for dealing with ExtJS 4 for unit testing using Karma test runner/ Jasmine 1.x and 2.0 versions and dealing with Async Issues: here they are: https://github.com/cgauthier/karma_jasmine_1_extjs4 and https://github.com/cgauthier/karma_jasmine_2_extjs4. The trick to loading external references is to add them as files in your modules declaration.

cg_coder
  • 136
  • 1
  • 3