qunit

RequireJs loading modules - Qunit

ぐ巨炮叔叔 提交于 2019-11-28 12:36:51
I am pretty new to RequireJS, and having trouble in writing QUnit to a source code which has logic to load modules dynamically using requireJS. Below is the source code: factory/Factory.js * getPage: function (callback) { //doSomething here require(['page/something'], function() { callback(); }) } The module 'page/something' is never loaded while running QUnit, and callback is never invoked. Is there anything I'm missing here? Appreciate your response. * *QUnit factory/FactoryTests.js* define(['underscore', 'factory/Factory'], function (_, Factory) { module("Factory", { setup:function () { },

grunt not running QUnit tests on phantom

懵懂的女人 提交于 2019-11-28 12:18:43
I've got a repository which is integrated with travis. I've got QUnit tests which I'd like to run from grunt/node server side and AMD (requirejs). This is the source of my AMD init.js: (function () { require.config({ baseUrl: "../src" }); require(["../test/suites/basic", '../test/qunit-extend', 'qunit' ], function(BasicTests) { QUnit.config.autoload = false; QUnit.config.autostart = false; BasicTests.run(); QUnit.load(); QUnit.start(); }); }()); When I run those QUnit tests within my browser - everything works perfectly. But when I try to run them from grunt level (server-side using phantomjs)

Trailing spaces in Ajax response

十年热恋 提交于 2019-11-28 10:23:53
问题 I am trying to use Qunit to test some code, but I have some problems with Ajax calls. I cannot even get them to test correctly with the simplest Ajax call using jQuery methods. The problems seems to be that a trailing space is appended to the textResponse, no matter what I do. My initial code was something like asyncTest('Ajax calls', function() { expect(1); $.get('ajax.txt', {}, function(response) { equal(response, 'foo', 'Ajax calls work correctly'); }); setTimeout(function() { start(); },

How to Unit Test with Qunit a Knockout View Model that uses throttle on observables

不问归期 提交于 2019-11-28 05:19:41
问题 Supposed this is my view model function VM() { var self = this; this.Status = ko.observable(false); this.A = ko.observable(); this.B = ko.computed( function() { return self.A(); } ).extend( throttle: 200 ); this.B.subscribe( function() { self.Status(true); setTimeout( //ajax simulation function(){ self.Status(false); } ,200) } ); } I want a test that verifies status toggles between true and false as A is set but i can't get past the dual async nature of the VM. Is there a way to test this

Overriding check box in JavaScript with jQuery

偶尔善良 提交于 2019-11-28 02:22:55
Help with unit testing checkbox behavior. I have this page: <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(function() { $('<div><input type="checkbox" name="makeHidden" id="makeHidden" checked="checked" />Make Hidden</div>').appendTo('body'); $('<div id="displayer" style="display:none;">Was Hidden</div>').appendTo('body'); $('#makeHidden').click(function() { var isChecked = $(this).is(':checked'); if (isChecked) { $('#displayer').hide(); } else { $('#displayer').show(); } return false; });

How can I use HTML fixtures with Karma test runner using Qunit?

与世无争的帅哥 提交于 2019-11-27 10:20:59
问题 I'm playing with Karma test runner (http://karma-runner.github.io/0.8/index.html) using qunit (http://qunitjs.com). I succesfully created and ran simple tests (100% JavaScript), but now I'm trying to use HTML fixtures in order to test code that interacts with DOM nodes. I'm able to load these fixtures by declaring them in "files" in this way: {pattern: 'fixtures/myfixture.html', watched: true, served: true, included: false} it get served by karma's server, but I don't understand how can I

Running JavaScript unit tests headlessly in a Continuous Integration build

懵懂的女人 提交于 2019-11-27 09:07:20
问题 I have a webapp build plan running on a Continuous Integration system (Atlassian Bamboo 2.5). I need to incorporate QUnit-based JavaScript unit tests into the build plan so that on each build, the Javascript tests would be run and Bamboo would interpret the test results. Preferably I would like to be able to make the build process "standalone" so that no connections to external servers would be required. Good ideas on how to accomplish this? The CI system running the build process is on an

RequireJs loading modules - Qunit

假装没事ソ 提交于 2019-11-27 07:05:27
问题 I am pretty new to RequireJS, and having trouble in writing QUnit to a source code which has logic to load modules dynamically using requireJS. Below is the source code: factory/Factory.js * getPage: function (callback) { //doSomething here require(['page/something'], function() { callback(); }) } The module 'page/something' is never loaded while running QUnit, and callback is never invoked. Is there anything I'm missing here? Appreciate your response. * *QUnit factory/FactoryTests.js* define

Overriding check box in JavaScript with jQuery

匆匆过客 提交于 2019-11-27 04:53:16
问题 Help with unit testing checkbox behavior. I have this page: <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(function() { $('<div><input type="checkbox" name="makeHidden" id="makeHidden" checked="checked" />Make Hidden</div>').appendTo('body'); $('<div id="displayer" style="display:none;">Was Hidden</div>').appendTo('body'); $('#makeHidden').click(function() { var isChecked = $(this).is('

Ember CLI Code Coverage Reports

こ雲淡風輕ζ 提交于 2019-11-27 01:51:29
问题 I am using Ember CLI and I am trying to integrate code coverage reports with the built in Qunit tests that are run with testem. I tried to use Istanbul, but I couldn't get it to find the files to instrument because it seems to be looking in the tmp directory. I tried doing this in my testem.json: { "framework": "qunit", "serve_files": [ "instrumented/components/*.js" ], "before_tests": "istanbul instrument --output instrumented/components app/components", "after_tests": "istanbul report",