ember.js,qunit,ember-qunit,ember-testing
the click event doesn't set focus (being a back door route). You'll need to manually set focus then click if you want the same results. Ember's Click Helper (sends mousedown/mouseup, then click) function click(app, selector, context) { var $el = app.testHelpers.findWithAssert(selector, context); run($el, 'mousedown'); if ($el.is(':input')) { var type =...
There are lots of problems here. For one, you don't have any way to let the calling code know that your function has finished. Without that, QUnit can't determine when to run the assertions. Then you'll need to use QUnit's async ability, otherwise the test function finishes before your promise...
ember.js,rspec,qunit,poltergeist
test('clicking login authenticates', function(){ visit('/'); return pauseTest(); // The test will never proceed to execute this click click('a:contains(Login)'); }); Try to use pauseTest() while running the tests in the web browser: ember test --server The small window in the browser should pause and you can see its state. P.S. You...
I'm assuming you are doing .NET development in Visual Studio? That's the only place I've seen the /// <reference ... /> stuff. That is not actually including the source in your page, it is only used for the IntelliSense reference in your IDE. If you want to iunclude jQuery in...
javascript,unit-testing,phantomjs,getjson,qunit
Your login function should be asynchronous, because its result depends on a response from server. So let's rewrite the function like this: function login(user, pass, done) { $.getJSON(..., function (res) { done(res.status == 'success') }) } Then you can test like this (assuming mocha): describe('...', function () { it('login()', function...
javascript,unit-testing,jasmine,resharper,qunit
It's fixed in ReSharper 9.1.1!
ember.js,variable-scope,qunit,faye,karma-qunit
The reason of that weird behavior is related to the following lines in Faye: if (typeof module !== 'undefined') module.exports = Faye; else if (typeof window !== 'undefined') window.Faye = Faye; Source: https://github.com/faye/faye/blob/master/javascript/faye.js#L143 So if module is not undefined(meaning it is defined) then module.exports will be set object, if not,...
javascript,node.js,unit-testing,gruntjs,qunit
Are you using document.createTouch correctly? According to Safari developer you need to pass the view in which the event occurs (window). createTouch( DOMWindow view, EventTarget target, long identifier, long pageX, long pageY, long screenX, long screenY) touch1 = document.createTouch(window, div, 1, 0, 0, 0, 0); ...
It took a little bit of rethinking.. The quinit exception mechanism is a bit rudimentary for my needs.. This is the solution I reverted to, which is the test code started with before moving to qunit. There is one drawback, qunit will dump the backtrace if: QUnit.config.notrycatch = true; QUnit.test("Internal...
OK, I ended up just adding the button within the body of the test html document rather than through the qunit-fixture element. Now $("#btnSubmit").trigger("click"); triggers the actual event handler within the JS file under test. Oh, one other thing I did was mark the button as hidden which isn't necessary,...
The ember-qunit library that you are looking for can be downloaded from GitHub: https://github.com/rwjblue/ember-qunit-builds You can either access the library remotely: <script src="https://github.com/rwjblue/ember-qunit-builds/blob/master/ember-qunit.js"></script> Or you can download it locally, place it alongside your other scripts and include it by specifying the relative path to the library, replacing the remote path...
teardonw removes the iframe and in the next test you have to bring it up again. This way you can write separated tests that can be run standalone. An example is here: Opa sample with 2 isolated tests If you press the rerun button on test2 it will execute standalone...
function setupModule() { $('input[name="text"]').on('click', function() { $('.has-error').hide(); }) $('input[name="text"]').on('keypress', function() { $('.has-error').hide(); }); } module('tests', {setup:setupModule}); test("errors should be hidden on key press", function() { $('input[name="text"]').trigger('keypress') equal($('.has-error').is(':visible'), false); }); test("errors not be hidden unless there is a keypress", function() { equal($('.has-error').is(':visible'), true); }); test("errors should be hidden on click", function()...
angularjs,angular-ui,qunit,chutzpah
The issue is one of .js loading order. When you are running with code coverage the blanket.js plugin will instrument your files and cause them to load asynchronously. Since you were excluding your test files from instrumentation it was loading it before the source file. To change this just allow...
gruntjs,phantomjs,qunit,grunt-contrib-qunit
The QUnit grunt task uses the same globbing pattern matcher as most other tasks. Therefore, you can simply add a negated pattern to your target array of URLs: qunit: { all: ['Test/**/*.html', '!Test/**/ToBeExcluded.html'] } ...
javascript,visual-studio,unit-testing,qunit
You should add all the relevant logic of your application to your unit testing file so they all execute before you run your tests <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>QUnit Test Results</title> <link rel="stylesheet" href="/Content/qunit.css"> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"></div> <script src="/Scripts/qunit.js"></script> <script src="/Scripts/PlayerSkill.js"></script> <script...
I just realized that it is more simpler than my previous answer. Just add all properties that you want to access in all other test of modules in current object. QUnit.module("unrelated test", { setup: function() { this.usedAcrossTests = "hello"; // add it to current context 'this' } }); And then...
javascript,testing,ember.js,ember-cli,qunit
Author here! Sorry about it, I actually need to update the code since on the latest release the syntax for tests changed to match the upcoming version of QUNit. Now to use: equal, ok and the other QUnit's assertions, we have to do it through a param called assert in...
I wouldn't use inline styles--use CSS classes instead. In your view/component, just add classNameBindings: ['isVisible'],, and in your CSS you can use .is-visible { display: block; }. I would actually invert the logic on that, as something should be visible unless hidden, instead of hidden unless visible, but I think...
javascript,ember.js,ember-cli,qunit,ember-qunit
The assert object is a singleton instance which you can gain access with QUnit.assert. So the following should work import QUnit from 'qunit'; QUnit.assert.controlDisabled = function(selector, message) { return this.ok(findWithAssert(selector).attr('disabled'), message); }; ...
Knowing that the cause was that the JSONP call was failing on the background, in order to suppress this error during testing I had to add an error handler to the document object when the error was expected. errorNamespace = "error.test" $(document).on(errorNamespace, function(event) { ok(true, "Received expected error"); // Prevent...
javascript,backbone.js,qunit,sinon
The short answer is... events:{} This property is to capture the delegate events that happening in DOM(templates). e.g., button click event on()/bind() These methods is to capture internal events happening inside backbone eg., collection/model add event ...
Adding this as an answer from my comment, but honestly, it's unfortunate that it should have to be this way... It looks like you'll have to use the full options object with the urls set. See this example on their Github page. And here it is with your example: grunt.initConfig({...
store.filter doesn't actually load the records, it will only return records that are already in the store. What you probably want to do is something like... App.BooksRoute = Ember.Route.extend({ model: function() { var id = 1; // note: filters "books" properly but doesn't work in qunit return Ember.RSVP.hash({ books: this.store.find('books').then(function(books){...
I'm not sure if this is exactly how you want this to work, but I wanted to run a newer version of QUnit than the one that comes bundled with R#. The simplest solution I had was to include QUnit-1.17.1 into my project, and in the top of my JavaScript...
javascript,jquery,unit-testing,qunit,jasmin
The jQuery team uses Qunit for their testing. When I work on jQuery plugins, I tend to use the same tools. Here is an example test in Qunit: //In your JS function myTestFunction() { //code here } //In test.js QUnit.test( 'My Tests: ', function( assert ) { 'use strict'; var...
The test wasn't working on first try because of the order tests were ran. Subsequent run worked because failed test are run in first. So, my test weren't independent from each other because I declared variable "root" only once and applied the knockout binding. Because of this, each test leave...
I would recommend adding a callCount variable, and incrementing it by 1 each time a callback is invoked. Then you can expect(callCount).toBe(x) just before the call to done(). On the other hand, you can use Spies to achieve this as well: it("Should run callbacks with correct data", function(done){ var callback...
javascript,ajax,json,qunit,sinon
A couple comments on your test: jQuery ajax() documentation says that if the data parameter isn't a string, it will be converted to a query string using $.param(). You could avoid that conversion by passing a string. The last assert compares [Object].mockData to a variable named mockData. I'm guessing that's...
I think QUnit removes the element you added in the fixture before it runs each test. So the "keypress" event handler added on document ready is removed by the time the 2nd test starts. It will work if you add the event handler at the start of each test, or...
ember.js,integration-testing,webstorm,ember-cli,qunit
You should have used ember to run your code. And you are running it as a simple node.js application (node foo-test.js). Moreover, Node won't accept EcmaScript 6 syntax unless being run with --harmony switch. Please make sure to update your run configuration accordingly (to run ember and pass your spec...
You can use sinon.assert.callOrder(spy1, spy2, ...), or spy1.calledBefore(spy2) or spy2.calledAfter(spy1). These can also be used with the result of spy.calledWith(...), e.g. sinon.assert.callOrder(spy.withArgs('a'), spy.withArgs('b'))....
javascript,promise,qunit,rsvp.js,rsvp-promise
promises work by chaining. Promises are immutable wrappers over values. When you do: promise.then(function(e){ // do something }); You are not changing promise you are creating a new promise instead. Instead, you need to chain the promise: test('success test', function(assert) { assert.expect(1); var promise = loadGroups(testData); // return the `then`...
javascript,testing,anonymous-function,qunit
TL;DR: This is exactly how the throws() assertion in QUnit is intended to work, and how it must work. Long, drawn out response: In your example you are calling the assertion with the result of the call to sometimesThrows(false). That is to say, in your example above, when you call...
I have to start with the following words: I'm not good in QUnit. Nevertheless because I see that nobody else wrote an answer to you I decided to write my answer. The most problem is how to use unit tests. I know a lot of people who try to set...
javascript,ajax,unit-testing,asynchronous,qunit
Similar to test methods, you can use stop and start in your teardown code to pause the test runner until your clean-up code is done (asyncTest does an implicit call to stop). QUnit uses a counting semaphore for stop/start calls, so you can call stop multiple times if you've got...
javascript,ember.js,qunit,ember-qunit
Initializers are not run in unit tests componentForModel, therefore this.convertPercentage is undefined (as the error suggests). So my suggestion is to import the function from your model and just attach it: import convertPercentage from "../utils/convert-percentage"; export default DS.Model.extend({ salesTaxPercent: function(key, value, previousValue) { return this.convertPercentage.apply(this, arguments); }.property('salesTax') }); https://github.com/rwjblue/ember-qunit/issues/149#event-261578363...
unit-testing,ember.js,ember-cli,qunit,ember-qunit
Something along these lines maybe? import { moduleFor, test } from 'ember-qunit'; import Ember from 'ember'; var products = [ Ember.Object.create({ name: 'shoe', subTotal: 10 }), Ember.Object.create({ name: 'shirt', subTotal: 20 })]; var model = Ember.ArrayProxy.create({ content: Ember.A(products) }); moduleFor('controller:cart', { beforeEach() { this.controller = this.subject(); } }); test('cartTotal', function(assert)...
javascript,unit-testing,symfony2,qunit
You're talking about keeping your tests atomic with respect to the DOM, which is great! Don't give up! The basic idea is to have a version of the form in a "fixture" that is reset before/after each test in order to not have one test affect another (ensuring atomicity). You...
Hmm, I thought server.repond() was supposed to do that as well. In any case, I usually set up my fake server(s) to auto respond instead. Unless you need to inspect requests before responding this seems to be easier: var server; QUnit.module('fake server tests', { beforeEach: function() { server = sinon.fakeServer.create();...
Are you looking for a way to show that pushObject() works with observers, but modifying the array in other (non-Ember friendly) ways doesn't work? If so, I think this JSBin shows that. It seems as if a simple array bound to a Handlebars template is enough to show that push()...
You can't as it is not a trusted event. Events that are generated by the user agent, either as a result of user interaction, or as a direct result of changes to the DOM, are trusted by the user agent with privileges that are not afforded to events generated by...