Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Modify mock-ajax instructions in README.md #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,22 @@ Under Windows 7, you have to launch `C:\Users\[UserName]\AppData\Local\Google\Ch

## Mocking with jasmine-ajax

[jasmine-ajax](https://github.com/pivotal/jasmine-ajax) library doesn't let user to manually start / stop XMLHttpRequest mocking, but instead it overrides XMLHttpRequest automatically when loaded. This breaks jasmine-jquery fixtures as fixture loading mechanism uses jQuery.ajax, that stops to function the very moment jasmine-ajax is loaded. A workaround for this may be to invoke jasmine-jquery `preloadFixtures` function (specifying all required fixtures) before jasmine-ajax is loaded. This way subsequent calls to `loadFixtures` or `readFixtures` methods will get fixtures content from cache, without need to use jQuery.ajax and thus will work correctly even after jasmine-ajax is loaded.
[jasmine-ajax](https://github.com/pivotal/jasmine-ajax) library let user to manually start / stop XMLHttpRequest mocking since v2.0.0 for sure. after ajax mock installed, it overrides XMLHttpRequest and breaks jasmine-jquery fixtures as fixture loading mechanism uses jQuery.ajax, that stops to function. So, just load fixtures first, then install the ajax mock.

beforeEach(function(){
// first load your fixtures
loadFixtures('fixture.html');

// then install the mock
jasmine.Ajax.install();
});

afterEach(function () {
// finally uninstall the mock
jasmine.Ajax.uninstall();
});

Older version doesn't let user to manually start / stop XMLHttpRequest mocking. A workaround for this may be to invoke jasmine-jquery `preloadFixtures` function (specifying all required fixtures) before jasmine-ajax is loaded. This way subsequent calls to `loadFixtures` or `readFixtures` methods will get fixtures content from cache, without need to use jQuery.ajax and thus will work correctly even after jasmine-ajax is loaded.

## Testing with Javascript Test Driver

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "jasmine-jquery"
, "description": "jQuery matchers and fixture loader for Jasmine framework"
, "version": "2.0.5"
, "main": "./lib/jasmine-jquery.js"
, "keywords": ["jasmine", "jquery"]
, "homepage": "http://github.com/velesin/jasmine-jquery"
, "author": {
Expand Down