I have a scenario where I am calling the jquery ajax inside jquery.ready function. So as soon as this js gets loaded in page, ajax call gets submited. I am writing jasmine test cases for this js. Problem is, when I include this js in my specrunner.html for writing jasmine test, jquery.ajax gets called, as it is inside jquery.ready. I want mock this ajax call. I already tried using jasmine ajax, but no help. Please help.
How to mock jquery ajax calls, written in jquery.ready function using jasmine test
540 Views Asked by csjoshi04 At
1
There are 1 best solutions below
Related Questions in JQUERY
- How to sort these using Javascript or Jquery Most effectively
- Ajax jQuery firing multiple time display event for the same result
- .hover() seems to overwrite .click()
- Check for numeric value with optional commas javascript
- Extending Highmaps Side Effect
- Array appending after each onclick and loop in javascript
- how can i append part of a table based on how many tr it has?
- Play multiple audio files in a slider
- Remove added set of rows
- Access property of an object of type [Model] in JQuery
- AJAX PHP - Reload div after submit
- proengsoft/laravel-jsvalidation ReferenceError: jQuery is not defined
- when a checkbox is checked how to display a different hidden element using javascript
- Get jquery error Uncaught RangeError: Maximum call stack size exceeded
- Removing only the closest thead on table filtering
Related Questions in TESTING
- How does Robot's Telnet library work?
- Behat doesn't load extensions?
- Load additional CONFIG file with values
- rails controller test failing non-deterministicly wrt state leak (I think)
- Ordering tests using trial twisted
- Unexcepted failed Gavel/Dredd test
- How to use Jasmine and CucumberJS with Protractor
- Django login tests session problems
- How to mock specific RequireJs dependencies while unit testing
- Test case for WCF REST Service
- how to test this business logic
- Protractor - How to get first or last CHILD value
- Factory Not Registered in rspec but found in console
- Pick out certain lines from files
- Selenium stops running after click() function runs
Related Questions in JASMINE
- How to write tests for classes with inheritance
- karma-ng-html2js-preprocessor not able to GET template
- Stubbing an angularJs service with a function that returns a promise using sinon
- How to use Jasmine and CucumberJS with Protractor
- jasmine unit test case for slider directive
- JQuery Unit Testing tooltips (jasmine, qunit, etc..)
- how to mock $state.params in jasmine unit testing
- How do I support jasmine and es6 syntax in Visual studio Code?
- Jasmine spyOn with multiple returns
- Why does Jasmine toEqual return true when comparing empty array with empty object?
- Mocking Angular $window in unit test cases
- Checking variable value with Jasmine
- adding a utility namespace in JasmineJS
- require.config TypeError: undefined is not a function
- Unit testing scope function
Related Questions in GUI-TESTING
- Java Swing GUI Test Fest JPanel Fixture Error
- Cannot get automac python package to work. Error = import: command not found
- Questions on UFT/QTP 11.53
- Making pytest wait for user input
- is it possible to do low-level pixel inspection with selenium?
- FEST JUnit-Swing testing noobQ: how to test a main class?
- No connection to Authorization server. Testdroid plugin for eclipse
- How to do automated UI testing of devexpress controls?
- UFT doesn't click a WebCheckBox of a pop-up
- How to test Web UI of a Web Browser control inside a WinForms application?
- Making FEST to wait for the application to load
- How to Mock MVC4 application when UI testing with Watin?
- Test Activity which is located in tests AndroidManifest
- How to mock jquery ajax calls, written in jquery.ready function using jasmine test
- automate testing of application executable file (windows based application)
Related Questions in JASMINE-JQUERY
- Checking variable value with Jasmine
- Trigger resizable in jasmine
- How to mock jQuery with Jasmine
- How to write JavaScript Integration Tests?
- Jasmine: Testing a function, being called from a different function using jasmine
- Unit testing with Jasmine, expect().toBeVisible()
- Jasmine doesn't seem to be calling my method
- test cases using Jasmine for each scenario
- How to test whether an input form field is focussed?
- jasmine text verification: How to normalize text?
- Mocking dependent modules using Jasmine
- Where do I put HTML fixtures when I'm using JsTestDriver?
- Jasmine Clock mocking and JQuery effect 'complete' function does not go along well
- .toHaveBeenCalled() true when should be false
- Jasmine spy element onload
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Do you want to mock the AJAX call, or the response? If it's the latter, In the past I used to mock it with Sinon's fake server. Now (Jasmine 2.X) has it's own fake XHR facility. In general you will have in the beforeEach something such as:
Then after you send your request, you'd run:
and