Questions tagged [qunit]
QUnit is a JavaScript unit testing framework, used by the jQuery project to test its code and plugins, but capable of testing any generic JavaScript code (both on the client and on the server).
1,111
questions
0
votes
1
answer
23
views
Why is Istanbul with Qunit able to see my source files, but does not measure their coverage?
I’m creating some modules to work with three-js and since that project uses Qunit, I’m sticking with that.
Qunit is running my test scripts correctly. I read a couple quick tutorials on coverage ...
1
vote
1
answer
59
views
Karma, Qunit, Typescript, UI5 does not work when using "import" statement
Iam trying to set up my tests to run with Qunit, Karma UI5, and Typescript but I seem to have some probable's with module resolution.
This is my tsconfig
{
"compilerOptions": {
"...
0
votes
0
answers
16
views
Change text of DOM content after click in test case of QUnit
My goal is to test that the content of an HTML element changes after triggering an event. While browsing through discussions about this, I discovered that it is possible to trigger the "click&...
0
votes
0
answers
13
views
chutzpah test explorer adapter in VS 2022 is including test cases from some dependency project as well. How do I filter that out?
I have Qunit test cases written in my project. I am using chutzpah test explorer adapter to manage those test cases in VS test explorer. I can see all test cases from my project and also test cases ...
0
votes
1
answer
22
views
karma config fails to add external project or file in the current project
I have added unit tests in some frontend projects using karma. I have multiple projects in my Git folder. If I run them individually, they work fine. However if there is a dependency of one project in ...
2
votes
1
answer
60
views
How to write Qunit for attachEventBrowser in UI5
I have a code snippet for which I have to increase code coverage
Following is my controller-
I need to have statements in my qunit for the bold section
sap.ui.define([
"sap/ui/core/mvc/...
1
vote
0
answers
23
views
ES5 : mocha and qunit.js
I have qunits written using QUnit.js, now I am trying to integrate Qunit.js with mocha so that I can execute both unittests with single mocha command.
I have installed qunit and mocha using npm.
➜ npm ...
0
votes
1
answer
103
views
Ember acceptance tests fail when ran all at once
I have about 5 acceptance tests which all pass when ran individually. When I want to run all of my tests, the acceptance tests will fail, except for the first one that was ran. All acceptance tests ...
1
vote
0
answers
76
views
Emberjs acceptance test not rendering DOM elements
When running a series of acceptance tests, only the first one will correctly work. All those who follow will not even render the DOM. I've tried looking for the reason but haven't been able to find a ...
0
votes
0
answers
130
views
Use QUnit to test a function that use DOM function ( document.querySelector() )
Sorry for my english
I'm a very new in world of test.
I'm trying to test some functions of an object named portail_functionnality
/**
* All functionnality and state of portail
*/
let ...
0
votes
1
answer
309
views
how to mock/test a window.prompt feature using sinon.js
I have a javascript function hat uses prompt to ask details from user:
export function askUserForTeamDetails() {
const emoji = window.prompt( 'Enter new team’s emoji:' );
if ( null === emoji ) ...
1
vote
0
answers
170
views
How to fix 'Assertion occurred after test had finished' with Qunit
I have a function for an animation that uses a callback. The function uses promises:
export function createExpandCollapseCallback(
containerSelector,
toExpandCollapseSelector,
...
0
votes
1
answer
52
views
QUnit - Testing functions of files besides formatter.js
The example given by UI5 of testing the formatter functions i.e.
// Assert
assert.strictEqual(fnIsolatedFormatter("A"), "New", "The long text for status A is correct");
...
1
vote
0
answers
94
views
Using QUnit CLI - Having issues with import / export syntax
I think the issue is with differences using ES Modules vs Common JS Module vs Webpack, but I have come here to actually find out what's wrong!
Basically I have QUnit set up and running fine through ...
0
votes
1
answer
52
views
Converting test project from AMD to ES6 causes issue Qunit Asynctest cases
I am migrating/converting my test utilities project to ES6.
I am using "@types/qunit": "^2.0.31" version to execute async test cases.
All went well before conversion but after ...
0
votes
0
answers
256
views
How to check code coverage in Qunit test framework
We have tried to implement Istanbul and Karma both in separate workspaces.
Istanbul:-
We have installed nyc packages to run test cases.
After that when we run nyc qunit, we are getting below error in ...
1
vote
0
answers
125
views
Using sinon to spy/stub document.submit()
I have the following function called on Init() of SubmitCodePage:
TrySubmit: function () {
var $submitButton = $("#submitButton");
if (!$submitButton.is(':disabled')...
1
vote
1
answer
44
views
Why does the value of $ change in a qunit test?
I'm running jquery 3.3.1, qunit 2.11.2, MacOS Chrome 87.0.4280.67
I have some code which works correctly when I run it in production, but fails under qunit. Investigating, it looks like $ has ...
1
vote
0
answers
189
views
How to explicitly test for a promise to resolve in QUnit
In QUnit, it is possible to check for a promise to reject:
assert.rejects(Promise.reject(new Error("some error description")), "promise rejected");
However, there is no assert ...
2
votes
1
answer
59
views
Is there a way for getting a list of all created tests in my emberjs app?
I need a way to get all my ember tests' nameS, since I want to run them in a separate thread by using the --filter "TEST-NAME" flag.
Right now, I am using a hardcoded array.
1
vote
1
answer
127
views
Using qunit and sinon to test a jquery click
I have the following method in my code:
SignUpEvents = function () {
return {
Init: function () {
$("#payBtn").click(function () {
EventTracker....
1
vote
2
answers
396
views
Library with identifier QUnit is missing - G Suite for Education Account
I have been trying to use QUnit to test my code but have been getting this error: "Library with identifier QUnit is missing (perhaps it was deleted, or maybe you don't have read access?)."
I ...
0
votes
1
answer
91
views
Why is qunit test returning wrong value
I have the following function:
MarketingHandler = function () {
return {
Init: function () {
$(document).on("click", "#verify .modal-close", function ()...
0
votes
1
answer
185
views
Testing function which checks if cookies are enabled with Qunit
I have the following function which checks if cookies are enabled in a user's browser:
CookiesEnabled: function() {
var cookieEnabled = navigator.cookieEnabled;
if (!cookieEnabled) {
...
0
votes
0
answers
97
views
How to write test cases for a function calling another function in qunit?
I have a function A which looks like this in controller1.
This function calls another function B in controller 2.
Can someone help me write qunit for this ?
A: function(){
//This function calls ...
0
votes
0
answers
83
views
Ensure cleanup code runs in an async QUnit context
I am trying to understand how to implement clean-up code after a QUnit test which involves an event being triggered asynchronously.
I have seen this answer. But for one thing, try as I might, I don't ...
0
votes
1
answer
304
views
I tried to maka a QUnit async test for checking ajax update
I tried to maka a QUnit async test for checking ajax update.
I read of QUnit.asyncTest here
https://www.sitepoint.com/test-asynchronous-code-qunit/
but if i try this i get a
TypeError: QUnit.asyncTest ...
1
vote
0
answers
111
views
How To 'check' A Checkbox In A JQuery Test
I am testing a function which changes a div's display from 'none' to 'block' when a checkbox is 'checked'. The code works on the website and I have another test on the same piece of code which passes (...
0
votes
1
answer
185
views
Pass parameters to a method which is expected to throw an error?
First steps with QUnit. Apologies if this is hyper-simple. I'm trying to understand things from this page of the manual.
If I have this:
QUnit.test( 'test init throws', function( assert ){
...
1
vote
0
answers
26
views
Is there a way to start all QUnit tests from different projects at the same time in SAP WebIDE?
I have different projects in my SAP WebIDE and each one have it's own QUnit-tests. When I will running my QUnit-tests, I can start it for each project seperately. But is there a way, that I can start ...
2
votes
0
answers
54
views
QUnit testing AJAX calls
I am trying to figure out how I would run a QUnit test on an AJAX call, I've searched on the web and also on here however, I'm still a little lost. I have an AJAX call which essentially just goes to ...
1
vote
0
answers
59
views
QUnit Test failing when it should be passing - JS
I have a javascript function where only 1 unit test is passing, when 2 of them should be passing, could someone point out the error. For some reason unit test number 3 is not passing, but unit test 4, ...
1
vote
0
answers
33
views
Setting up QUnit tests for AJAX calls
I am attempting to use Q-Unit Testing for my code. I would like to run some tests against my AJAX queries to ensure they are running ok and returning what they should.
Is there anyway I could get ...
1
vote
1
answer
295
views
Q-Unit Global Failure
I have just attempted to set up Q-Unit Testing, for my javascript functions. However, I seem to be getting an error of Global Failure
Within my JS file : script.js, I have to have the test code above ...
1
vote
1
answer
103
views
JS function scope defined in object not working for code coverage
I have a function which is defined in side an object. I have used Qunit to write test cases. When I try to generate code coverage report it gives me error var test is not defined.
JS file
$(function(...
2
votes
0
answers
279
views
How to organise unit-test for the javascript files in a django project so they can be run from CLI and be integrated to Gitlab-CI script?
I have made my project alone and as a hobby and looking for the professionnal methodology to do it:
I have got my django project oganised in a standard way:
Myproject
+-- App1
│ +-- migrations
│ ...
0
votes
1
answer
289
views
I can't import a module without errors
My problem is in the title. I wrote a class like so:
export default class Vector3 {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
// object's functions
magnitude() ...
0
votes
2
answers
239
views
stub performance.now() using Sinon.js
I am writing unit tests in Ember-qunit. I want to set a custom value on performance.now.
I tried sinon.stub(performance,'now', 60000); but this didn't work. I get TypeError: stub(obj, 'meth', fn) has ...
0
votes
0
answers
109
views
Failing following the basic QUnit for GAS tutorial
I tried to follow rigorously this basic "QUnit for Google Apps Script" tutorial: https://blog.ohheybrian.com/2019/11/unit-testing-gas-part-1-qunit-setup/
But when I connect to the deployed web-app, I ...
1
vote
1
answer
346
views
QUnit not found
I have the following code in javascript, call persona.js:
var PrototipoPersona = {
nombre : '' ,
primerApellido : '',
segundoApellido : ''
}
getNombre = function(){...
0
votes
1
answer
919
views
Unit testing that localStorage.getItem has been called on document ready?
I have the following code, whereby a localStorage item is checked on document ready. If a localStorage item has not been set yet, it's set:
$(document).ready(function () {
...
5
votes
1
answer
744
views
Can I setup a QUnit hook to run before all tests in a suite?
I'm using ember-qunit and have a service in my app that makes some nontrivial api calls. To handle this, I'm using a test helper:
// tests/helpers/mock-my-service.js
import { mock } from 'ember-data-...
1
vote
2
answers
595
views
How does the qunit knows when the async test callback is complete even though the tests does not return promise?
Qunit executes the async tests one by one, but how does it know a test is complete, since the tests does not return a Promise which the qunit can await?
In this demo example https://jsfiddle.net/...
1
vote
1
answer
224
views
Asserting an exception in QUnit
I am working on a unit test that is testing a generated parser code from a grammar. ( generated via PegJS)
Im almost finished with most of the cases that are possible. There are 2-3 of them left and ...
4
votes
1
answer
767
views
Ember concurrency timeout hanging in qunit
In Ember I have a component that starts a never-ending poll to keep some data up to date. Like so:
export default Component.extend({
pollTask: task(function * () {
while(true) {
yield ...
1
vote
1
answer
488
views
setApplication breaks ember-qunit test context
I recently upgraded an Ember app from 2.18 to 3.13 which went smoothly. Today I tried to add an acceptance test for the first time (only had integration / unit tests before this) but the test is ...
1
vote
2
answers
368
views
How can I add properties to a component in a unit test before init?
I'm working on an Ember component with an init function that I'd like to add a unit test for. The component has the following properties:
1) The init function must not be run more than once, and
2) ...
1
vote
0
answers
258
views
Generate Test Report with QUnit
I've got a NodeJS application with some QUnit tests. Let's say they look something like this:
magic.js:
function doMagic(input) {
return "Hello " + input + "!";
};
module.exports = doMagic;
And ...
0
votes
2
answers
59
views
How to set width of a control inside a function for QUnit test?
I have a scrollContainer which I need to set the width of. However, i'm not sure how to access the width inside my test file.
I can access the controller through
this.oViewStub = new Control()
var ...
1
vote
1
answer
1k
views
How to import modules for unit tests with QUnit
I've been trying to add unit tests for some modular ES6 code. I have a project structure like this:
project
└───src
| └───js
| cumsum.js
| index.js <--- entry point
└───test
...