qunit

Waiting in QUnit tests

旧巷老猫 提交于 2019-12-06 17:30:35
问题 I have jQuery code that when I click on a link it first hides and then removes some HTML, like so: $(this).parent().parent().hide('slow', function () { $(this).remove(); }); I want to make a QUnit test that makes sure that the HTML in question was deleted: $(thelink).click(); // Check that it is gone, by finding the first item in the list entity = input.form.find('.recurrenceinput_occurrences .occurrence span.action a')[0]; // And make sure it's NOT the deleted one: ok(entity.attributes.date

Is it possible to run a single test using QUnit inside Karma?

被刻印的时光 ゝ 提交于 2019-12-06 08:52:50
Jasmine has iit() and ddescribe , and Mocha has it.only and describe.only , but I can't see any way to get QUnit to focus on running a single test. The QUnit UI allows you to run a single test, but I can't see how to get this to work inside Karma, because it doesn't display the QUnit UI. Here is my solution. It works fine for me, but YMMV. Download qunit-karma-setup.js, qunit-karma-launch.js from here Then, in your Gruntfile: config.set({ frameworks: ['qunit'], files: [ 'your-app-files-here/**/*.js', 'qunit-karma-setup.js', 'your-tests-here/**/*.js', 'qunit-karma-launch.js' ] }); Now, you can

Unknown $rootElementProvider: Qunit + angularjs integration [closed]

只愿长相守 提交于 2019-12-06 00:03:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . When I try to inject $location service in unit test (qunit) I get error: Unknown $rootElementProvider <- $rootElement <- $location Other things without $location service dependency are injected correctly. var $injector = angular.injector(['ng', 'myApp']); var $location = $injector.get('$location'); source: http:

qUnit: Twitter Bootstrap modals writing outside of qunit-fixture

﹥>﹥吖頭↗ 提交于 2019-12-05 20:39:02
I'm having a difficult time writing qUnit tests for a project that uses Twitter's Bootstrap. When a modal is spawned it is putting the overlay outside of the qunit-fixture, so when the next test is run the overlay is not removed. Anyone run into this problem? Click event (linking to a jsfiddle requires some inline code, please look at the fiddle): $("#qunit-fixture").on('click', '#click', function () { $('#error').modal('show'); }); Example: http://jsfiddle.net/Gbyza/4/ Notice how the screen gets darker with each test? This is the overlay not being reset with each successive test. One other

Post-mortem unit testing

一世执手 提交于 2019-12-05 18:16:08
问题 I do version control with Git, and unit testing with QUnit. Sometimes I find a bug in my software that was not present in a past version. It's easy for me to write a unit test specifically for that bug. Given that unit test, can I easily go trough all my past commits and test the build with that unit test, so that I can pinpoint which commit caused the breakage? 回答1: Use git bisect for this, please see this page. Since you're testing JavaScript, you will probably have to run the tests by hand

Using Chutzpah to run Typescript qUnit tests

拥有回忆 提交于 2019-12-05 17:27:02
I've recently tried to incorporate qUnit and Chutzpah to unit test a project I'm working on which is written in typescript. I've got things setup in what I believe is the correct manner and the following things work: The typescript application! - I can run a very early version of the application Chutzpah - I installed this on VS2012 and it correctly see's my qUnit demo test qUnit - Appears installed and works with Chutzpah, I can run a simple test (one which doesn't look at my code) With these three in place I presumed I could begin to write tests for the typescript app, as a test I wrote a

'equal' is not defined : Ember-qunit does not seem to be importing

守給你的承諾、 提交于 2019-12-05 09:07:18
It appears the Qunit test methods aren't available even though I'm pretty sure I am importing them correctly. I get the following errors: unit/models/friend-test.js: line 11, col 3, 'ok' is not defined. unit/models/friend-test.js: line 17, col 3, 'equal' is not defined. unit/models/friend-test.js: line 23, col 3, 'equal' is not defined. unit/models/friend-test.js: line 31, col 3, 'equal' is not defined. unit/models/friend-test.js: line 32, col 3, 'equal' is not defined. I have this test file unit/models/friend-test : import Ember from 'ember'; import { moduleForModel, test } from 'ember-qunit'

Using .findBy() with Ember-data-populated array controller

删除回忆录丶 提交于 2019-12-05 08:04:46
Background I'm writing some functional tests to test that my router is navigating and loading my models correctly. So far, so good--even in light of this issue. I've created a fiddle , for your enjoyment. It doesn't work--I've never had much luck with jsfiddle and ember, in spite of forking @wagenet . But it has more source code to help get an overall picture of what I have going on. My Biggest Gripe So my biggest gripe is that the following code doesn't work to retrieve an element with a known id from a controller: var controller = App.__container__.lookup("controller:postsNew"); var

Checking if image properly loaded with Qunit

ぐ巨炮叔叔 提交于 2019-12-05 05:46:35
I'm trying to validate image URLs with Qunit by setting the URL as the src attribute of a test image and checking with the error event handler whether that went well. So far what I have is: test('image',function() { var test_image = $('#test-image'); test_image.error(function(e) { // properly triggered console.log(e); is_valid = false; // ok(false,'Issue loading image'); breaks qunit }); var is_valid = true; test_image.attr('src','doesntexist'); console.log('checking is_valid'); // occurs before error event handler if (is_valid) { // therefore always evaluates to the same ok(true,'Image

How do I extend QUnit with new assertion functions?

╄→гoц情女王★ 提交于 2019-12-05 05:05:53
I'd like to add new assertions to QUnit. I've done something this: QUnit.extend(QUnit.assert, { increases: function(measure, block, message){ var before = measure(); block(); var after = measure(); var passes = before < after; QUnit.push(passes, after, "< " + before, message); } }); When I use increases(foo,bar,baz) in my test, I get ReferenceError: increases is not defined From the browser console I can see increases is found in QUnit.assert along with all the other standard functions: ok , equal , deepEqual , etc. From the console, running: test("foo", function(){console.log(ok) }); I see