Jasmine-jquery loadFixtures with Jasmine 2.0 will not work

I spent about a day debugging, and I'm at a loss. Something seems to not work in jasmine-jquery 2.0.2.

I am updating Jasmine 1.3.1 and jasmine-jquery 1.5 to the latest versions. I get various crashes depending on how I try to load the fixtures. I get: "Fixture cannot be loaded: ./ ExposureWorksheetFixture.html (status: parsererror, message: Invalid XML" after I configured jasmine-jquery to provide parameters to the ajax.fail () method.

Another effect that I have when I pick up a jasmine sample and tests, says: "Zero lights, zero failures." This happens when I refer to jasmine-jquery, jquery 1.10.2 and try to install the fixtures. If I delete the operation (but leave the links), the sample will work.

Another error I get when I try to load devices is "(status: error, message: access to restricted URI is denied)". This happens when it is actually trying to download a file that is in the designated location. I saw another question that pointed to jquery requiring a real web server to download files, and it does not like the path to the local file, but I do not have this problem with older versions of these libraries. This happens in Firefox. I get TypeError: Object doesn't support this property or methodin IE 8. In Firefox, I get Error: Fixture could not be loaded: spec/javascripts/fixtures/fixture.html (status: error, message: A network error occurred.).

Here is a sample code ...

In PlayerSpec.js:

jasmine.getFixtures().fixturesPath = "./";
...
beforeEach(function() {
  player = new Player();
  song = new Song
loadFixtures("fixture.html");
});

In SpecRunner.html, pay attention to additional links to jquery and jasmine-jquery:

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Jasmine Spec Runner v2.0.0</title>

  <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.0.0/jasmine_favicon.png">
  <link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.0/jasmine.css">

  <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
  <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
  <script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
  <script type="text/javascript" src="lib/jquery-1.10.2.js"></script>
  <script type="text/javascript" src="lib/jasmine-jquery.js"></script>

  <!-- include source files here... -->
  <script type="text/javascript" src="src/Player.js"></script>
  <script type="text/javascript" src="src/Song.js"></script>

  <!-- include spec files here... -->
  <script type="text/javascript" src="spec/SpecHelper.js"></script>
  <script type="text/javascript" src="spec/PlayerSpec.js"></script>

</head>

<body>
</body>
</html>

Exit to the runner (first test - all tests do not work)

Jasmine2.0.0finished in 0.019s

raise exceptions5 specs, 5 failuresSpec List | Failures
Player should be able to play a Song
Error: Fixture could not be loaded: spec/javascripts/fixtures/fixture.html (status: error, message: Access to restricted URI denied) in file:///D:/Temp/jas/lib/jasmine-jquery.js (line 132)
jasmine.Fixtures.prototype.loadFixtureIntoCache_/request<@file:///D:/Temp/jas/lib/jasmine-jquery.js:132 jQuery.Callbacks/fire@file:///D:/Temp/jas/lib/jquery-1.10.2.js:3048 jQuery.Callbacks/self.add@file:///D:/Temp/jas/lib/jquery-1.10.2.js:3094 jasmine.Fixtures.prototype.loadFixtureIntoCache_@file:///D:/Temp/jas/lib/jasmine-jquery.js:131 jasmine.Fixtures.prototype.getFixtureHtml_@file:///D:/Temp/jas/lib/jasmine-jquery.js:115 jasmine.Fixtures.prototype.read@file:///D:/Temp/jas/lib/jasmine-jquery.js:77 jasmine.Fixtures.prototype.load@file:///D:/Temp/jas/lib/jasmine-jquery.js:65 jasmine.Fixtures.prototype.proxyCallTo_@file:///D:/Temp/jas/lib/jasmine-jquery.js:161 window.loadFixtures@file:///D:/Temp/jas/lib/jasmine-jquery.js:763 @file:///D:/Temp/jas/spec/PlayerSpec.js:9 attemptSync@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1510 QueueRunner.prototype.run@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1498 QueueRunner.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1485 Env/queueRunnerFactory@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:518 Spec.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:309 Suite.prototype.execute/wrapChildAsAsync/<@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1708 attemptAsync@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1520 QueueRunner.prototype.run@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1496 QueueRunner.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1485 Env/queueRunnerFactory@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:518 Suite.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1696 Suite.prototype.execute/wrapChildAsAsync/<@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1708 attemptAsync@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1520 QueueRunner.prototype.run@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1496 QueueRunner.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1485 Env/queueRunnerFactory@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:518 Suite.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1696 @file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:541 attemptAsync@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1520 QueueRunner.prototype.run@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1496 QueueRunner.prototype.execute@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:1485 Env/queueRunnerFactory@file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:518 @file:///D:/Temp/jas/lib/jasmine-2.0.0/jasmine.js:548 window.onload@file:///D:/Temp/jas/lib/jasmine-2.0.0/boot.js:170 

2/13/14 @8:32 pm est: jasmine-jquery, , , (Jasmine 1.31). , -: (

+4
3

travisjeffery . , . , , , , , . . , , , .

, HTML-Fixture, jasmine-jquery 1.5, 2.0.2. , , , , , script . , html, . , XML-, BAM! .

, jasmine-jquery script boot.js, "0 0 ". Jasmine, . , .

+4

jasmine-jquery.

jasmine jasmine-jquery , , ajax, , . jasmine-jquery README: https://github.com/velesin/jasmine-jquery/#cross-domain-policy-problems-under-chrome

+3

Thanks. I added this to spec_helper.js.coffee:

# rake spec:javascript loads specs relative to the tmp/jasmine/runner.html, need to override:
jasmine.getFixtures().fixturesPath="../../spec/javascripts/fixtures"
0
source

Source: https://habr.com/ru/post/1526801/


All Articles