qunit

Unit testing AJAX requests with QUnit

让人想犯罪 __ 提交于 2019-12-03 10:03:05
问题 We are trying to implement QUnit JavaScript tests for a JS-heavy web app. We are struggling to find a way to successfully test methods that involve jQuery AJAX requests. For example, we have the following constructor function (obviously this is a very simplistic example): var X = function() { this.fire = function() { $.ajax("someURL.php", { data: { userId: "james" }, dataType: "json", success: function(data) { //Do stuff } }); }; }; var myX = new X(); myX.fire(); We are trying to find a way

How to run QUnit test and get back test result in C# via JavaScript callback?

两盒软妹~` 提交于 2019-12-03 08:55:26
In my several projects, I use MVC pattern for separating code (of concerns) into 3 tiers. Both of Model and Control tiers run on C# so I use testing framework like MSTest or NUnit to validate functional requirement for these tiers. For View tiers, I use QUnit to test JavaScript files. However, I cannot execute QUnit as automated test because MSTest doesn't directly support for testing web page. I need to run it in MSTest like the following logic. [TestMethod] public void JavaScriptTest() { var result = QUnit.Test('~/QUnit/test1.htm'); Assert.IsTrue(result.Failed <= 0) } Solution must use

Testing Javascript that Manipulates the DOM

不打扰是莪最后的温柔 提交于 2019-12-03 06:23:01
问题 I've been looking into javascript test suites and I have found QUnit to be very interesting. I understand how to test computational code, but... How do you test javascript applications written primarily for DOM manipulation? it seems like testing the position/color/etc of DOM elements would be a moot point because you'd end up doing somethign like this: $("li.my_element").css("background-color", "#f00"); and then in your test... $(function() { module("coloring"); test("test_my_element",

BDD framework for the frontend?

混江龙づ霸主 提交于 2019-12-03 05:06:09
问题 On the server side we have Rspec/Cucumber for BDD development (ruby) vowsjs (node.js) Is there a BDD frameworks to use on web browsers (not qUnit or YUI test since these are only for TDD)? 回答1: Check out jasmine describe("Jasmine", function() { it("makes testing JavaScript awesome!", function() { expect(yourCode).toBeLotsBetter(); }); }); http://pivotal.github.com/jasmine/ https://github.com/pivotal/jasmine Should_be ( sic ) very familiar to a ruby person 回答2: You could also look at Yadda.

Better way to integrate maven/qunit/phantomjs?

南楼画角 提交于 2019-12-03 04:24:55
问题 I have been investigating the best way to do JS unit testing in our maven CI environment. What I currently have cobbled together is the following in my maven project: qunit resources (JS/CSS files) qunit test html files (one for each file under test) with html fixture if required index html file which references the test html files as an ordered list of hyperlinks PhantomJS runner file, which: opens the index html file and parses out list of test files opens each test file takes a screenshot

QUnit with Ajax, QUnit passes the failing tests

房东的猫 提交于 2019-12-03 03:07:54
I am looking into QUnit for JavaScript unit testing. I am in a strange situation where I am checking against the value returned from the Ajax call. For the following test I am purposely trying to fail it. // test to check if the persons are returned! test("getPersons", function() { getPersons(function(response) { // persons = $.evalJSON(response.d); equals("boo", "Foo", "The name is valid"); }); }); But it ends up passing all the time. Here is the getPersons method that make the Ajax call. function getPersons(callback) { var persons = null; $.ajax({ type: "POST", dataType: "json", data: {},

QUnit: How to test ajax call without modifying the ajax call

你说的曾经没有我的故事 提交于 2019-12-03 02:51:16
How can I write a QUnit test for this: function doSomethingWithAjax() { $.ajax({ url: '/GetHelloWorld', success: function(data) { $("#responseFromServer").text(data); }, }); } Mockjax+qunit requires a start() call in the ajax complete() method. test("should mock ajax", function() { $.ajax = function(options) { equals(options.url, "/GetHelloWorld"); options.success("Hello"); }; doSomethingWithAjax(); equal($("#responseFromServer").text(), "Hello"); }); The jasmine-ajax library allows you to define mock responses for all ajax calls without touching the calls themselves. This question has a few

Qunit + JSCoverage + Jenkins

匿名 (未验证) 提交于 2019-12-03 01:46:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have started using Qunit to test my JS code. I am looking into JSCoverage to generate the coverage reports later. We have a CI server (Jenkins) which already do a few things with our PHP code and I was wondering if anyone can comment on how I can integrate the report from my Qunit and JSCoverage into Jenkins Thanks Sparsh 回答1: QUnit: use QUnit API to generate junit XML files. Here's a sample . In Post-build Actions for your job you then check Publish JUnit test result report and specify your junit XML files (or their file pattern

QUnit vs Jasmine? [closed]

你离开我真会死。 提交于 2019-12-03 01:17:39
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . What are the main differences between these two testing frameworks? I am a totally new to Test Driven Development and starting from the very beginning. 回答1: QUnit is very easy to get started with, as you only need to include two files and a little bit of markup, then you can

Using Travis-CI for client-side JavaScript libraries?

匿名 (未验证) 提交于 2019-12-03 01:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm not sure to use Travis-CI for my client-side JavaScript library or not, because it compiles with NodeJs on Travis-CI servers. I want to know is this a good approach to use some kind of continuous integration such as Travis-CI for client-side libraries or not? 回答1: Yes of course you should use continous integration with client side libraries. I personally use PhantomJS (headless webkit browser) which is already installed in Travis-CI . I think this is the better option for client-side stuff than NodeJs. If you use Grunt , it gets even