Giter Site home page Giter Site logo

karma-qunit's Introduction

karma-qunit

npm version Build Status js-standard-style npm downloads

Adapter for the QUnit testing framework.

Installation

The easiest way is to keep karma-qunit as a devDependency in your package.json by running

npm install karma-qunit --save-dev

Configuration

Add qunit in the frameworks array in your karma.conf.js file. Then, in the plugins array, add karma-qunit. The following code shows the default configuration:

// karma.conf.js
module.exports = function (config) {
  config.set({
    frameworks: ['qunit'],
    plugins: ['karma-qunit'],
    files: [
      '*.js'
    ]
  })
}

You can also pass options for QUnit.config (documented here) as such:

/// karma.conf.js
module.exports = function (config) {
  config.set({
    frameworks: ['qunit'],
    plugins: ['karma-qunit'],
    files: [
      '*.js'
    ],

    // client configuration
    client: {
      clearContext: false,
      qunit: {
        showUI: true,
        testTimeout: 5000
      }
    }
  })
}

Note: showUI: true needs the clearContext: false option to display correctly in non-debug mode.


For more information on Karma see the homepage. If you're using karma-qunit to test Ember.js, you might find Karma's Ember guide helpful.

karma-qunit's People

Contributors

asapach avatar aymericbeaumet avatar crydust avatar dcherman avatar dependabot[bot] avatar dignifiedquire avatar eventualbuddha avatar johann-s avatar johnjbarton avatar krinkle avatar marcins avatar masubi avatar matt-stripe avatar pallxk avatar sahat avatar sechel avatar tailsu avatar thenickcox avatar ublock avatar vobu avatar vojtajina avatar xhmikosr avatar zzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

karma-qunit's Issues

Existing fixture should be preserved

Since #22 (v0.1.5) two QUnit features are broken in karma-qunit.

Firstly, qunit-fixture is not just a recipient for any dummy element that a user might want to have automatically cleaned up. It is also a place where one can put fixtures (surprise!) that will be available to every test.

QUnit has always torn down and re-created this element between tests, but its contents are saved from the first impression at startup and then re-parsed for each test. This behaviour has been part of QUnit since the first stable version and breaking of this behaviour is one of the reasons why it's been next to impossible to use karma-qunit for jQuery core's own test suite. (Something I'm trying as part of jquery/jquery#1999).

In current versions of QUnit, this first impression is saved in QUnit.config.fixture.

Also, contrary to the comment in adapter.js, QUnit's own runner does not create #qunit-fixture by default. The entire fixture feature is opt-in and implicitly enabled by the HTML test page having such element at startup.

Still, #22 was a much requested feature (for valid reasons), because at the time it wasn't supported by Karma to customise this HTML page (since it has its own context page instead). And even now that it is possible, it makes more sense to auto-create this given there's no downside to doing so.

So, three problems:

  1. Any pre-existing #qunit-fixture element should be preserved (e.g. when using a custom Karma's customContextFile option).
  2. QUnit.testStart runs after QUnit's own test start handler, which already re-creates the qunit-fixture every tests and repopulates it with a fresh parse of QUnit.config.fixture. Setting this config option is currently broken because karma-qunit removes the fixture and re-creates it.
  3. The element only needs to be created at QUnit.begin, not at every QUnit.testStart.

Error: No provider for "framework:qunit"! (Resolving: framework:qunit)

Just trying to get a simple test running, I'm getting a Error: No provider for "framework:qunit"! (Resolving: framework:qunit) error when running karma start.

I tried both adding it to my package.json (the same one from the README of this repo), and npm install karma-qunit --save-dev. Here is a gist of my karma.conf.js file. It's basically the default with frameworks: ['qunit'] set, and I added the paths to my js and spec files.

Here's all my node and npm versions and whatnot.

macbookpro@Nick-Coxs-Macbook-Pro ~/Sites/ember-firebase-groceries (master)
$ karma --version
Karma version: 0.10.10

macbookpro@Nick-Coxs-Macbook-Pro ~/Sites/ember-firebase-groceries (master)
$ npm -v
1.4.3

macbookpro@Nick-Coxs-Macbook-Pro ~/Sites/ember-firebase-groceries (master)
$ node -v
v0.10.26

Here's the full stack trace:

macbookpro@Nick-Coxs-Macbook-Pro ~/Sites/ember-firebase-groceries (master)
$ karma start

/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:qunit"! (Resolving: framework:qunit)
    at error (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/lib/server.js:28:14
    at Array.forEach (native)
    at start (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/lib/server.js:27:21)
    at invoke (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/lib/server.js:206:12)
    at Object.<anonymous> (/Users/macbookpro/Sites/ember-firebase-groceries/node_modules/karma/bin/karma:19:39)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

qunit-fixture is not reset between tests properly

#93 broke some of our tests which relied on the previous behavior of #qunit-fixture being reset on testStart by the adapter.

The tests basically do this:

QUnit.module("Test suite", {
    beforeEach: function () {
        $("#qunit-fixture").append(fixtures);
    }
});

The problem seems to be that QUnit begin handler runs before the adapter begin handler, which means that QUnit is not able to store QUnit.config.fixture element, because it's not created yet. So the #qunit-fixture element is not restored properly.

Here's the repro: https://github.com/asapach/karma-qunit-fixture

@Krinkle, could you please take a look?

Can not install with qunitjs 1.15.0

When defining qunitjs ~1.15.0 in my package.json which would resolve #7 I get following error.

Please update qunitjs to 1.15.0

npm ERR! peerinvalid The package qunitjs does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants qunitjs@~1.14.0

npm ERR! System Darwin 13.3.0
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! code EPEERINVALID

QUnit.todo() with a failure are reported as failling

I had the use case of a test being properly implemented but the feature code being incomplete and failing. When running the tests with the QUnit web interface, the test is not erroring out and is properly labeled todo.

qunit_todo_is_ok_on_web

However when running karma, the test is wrongfully reported as failing:

SUMMARY:
✖ 1 test failed

FAILED TESTS:
  ext.graph.visualEditor
    ✖ ve.ui.TableWidget
      Chrome 66.0.3359 (Linux 0.0.0)
    Died on test #4     at 
....
    TypeError: Cannot read property '0' of undefined
        at VeUiTableWidget.ve.ui.TableWidget.onInsertColumn   // expected failure
...
        at runTest (node_modules/qunit/qunit/qunit.js:1530:30)
        at Test.run (node_modules/qunit/qunit/qunit.js:1516:6)
        at node_modules/qunit/qunit/qunit.js:1728:12
        at advanceTaskQueue (node_modules/qunit/qunit/qunit.js:1129:6)
        at advance (node_modules/qunit/qunit/qunit.js:1110:4)

In lib/adapter.js I adjusted runner.testDone to print the test and testResult to the console which yields:

LOG: Object{
  name: 've.ui.TableWidget',
  module: 'ext.graph.visualEditor',
  skipped: false,
  todo: true,
  failed: 1,
  passed: 3,
  total: 4,
LOG: Object{success: false, errors: ['Died on test #4 ...

The testResult is set by runner.log which mark it with success = false. However in runner.testDone, the todo flag should be used to invert the result. Potentially:

--- orig.js	2018-06-26 22:31:26.880087441 +0200
+++ new.js	2018-06-26 22:32:36.218186993 +0200
@@ -8,6 +8,11 @@
 		time: new Date().getTime() - timer
 	}
 
+	// For QUnit.todo(): flip success report
+	if ( test.todo === true ) {
+		result.success = !testResult.success
+	}
+
 	if (result.description.indexOf('global failure') !== -1) {
 		return
 	}

Environment:

  • karma 2.0.2
  • karma-qunit 2.0.1
  • qunit 2.6.0

qunit-fixture has incorrect styles

Looks like my fix for #104 is incomplete.
Currently #qunit-fixture is being assigned some inline styles:

fixture = document.createElement('div')
fixture.id = FIXTURE_ID
// style to match qunit runner's CSS
fixture.style.position = 'absolute'
fixture.style.left = '-10000px'
fixture.style.top = '-10000px'
fixture.style.width = '1000px'
fixture.style.height = '1000px'
document.body.appendChild(fixture)

But since we now set runner.config.fixture as an empty string:
if (typeof runner.config.fixture === 'undefined') {
runner.config.fixture = ''
}

QUnit will wipe out those styles, because it creates a new element instead of re-using the existing one:
source

My initial suggestion was to save the element as runner.config.fixture = fixture, which fixes the issue, but as @Krinkle noted, the docs don't mention anything about it being a node.

Another potential fix would be to remove the inline styles entirely and rely on the QUnit CSS, which might be more future-proof. This means loading the CSS regardless of the showUI flag:

karma-qunit/lib/index.js

Lines 15 to 17 in a431d39

if (qunit && qunit.showUI) {
files.unshift(createPattern(require.resolve('qunit/qunit/qunit.css')))
}

What do you guys think?

Here's a repro: https://github.com/asapach/karma-qunit-fixture

running qUnit test: test is not defined

I'm trying to use this plugin to run qUnit tests.

Here my build.gradle:

plugins {
    id 'com.craigburke.karma' version '1.4.4'
}

karma {
    browsers = ['Chrome']
    frameworks = ['qunit']
    dependencies (['karma-qunit'])
    files = [
            'src/main/js/*.js'
    ]
 }

And here is the one and only qUnit test case:

test("This is another test", 1, function () { // use the "expected" param to register how many
    // assertions to Expect to be run within this test.
    ok(true, 'Look, a message!');
});

When I run gradle karmaRun, I'm see it opens new browser, and then fails with this error:

sfursov-mac:gradle-qunit sfursov$ gradle karmaRun

> Task :karmaRun
Chrome 63.0.3239 (Mac OS X 10.13.3) ERROR
  {
    "message": "Uncaught ReferenceError: test is not defined\nat src/main/js/test.js:1:1\n\nReferenceError: test is not defined\n    at src/main/js/test.js:1:1",
    "str": "Uncaught ReferenceError: test is not defined\nat src/main/js/test.js:1:1\n\nReferenceError: test is not defined\n    at src/main/js/test.js:1:1"
  }

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':karmaRun'.
> Process 'command '/Users/sfursov/.gradle/nodejs/node-v4.2.3-darwin-x64/bin/node'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
4 actionable tasks: 1 executed, 3 up-to-date

Here is complete project:
https://github.com/SlavikCA/gradle-qunit

Environment:

  • Mac OS 10.13.3
  • Gradle 4.2.1

Any idea, what I'm not doing right? Do I need to add qUnit dependency some other way?

QUnit 2.3.0 compatibility?

$ npm install karma-qunit --save-dev
npm WARN saveError ENOENT: no such file or directory, open '/foo/userscripts/package.json'
/foo/userscripts
├── [email protected] 
└── UNMET PEER DEPENDENCY qunitjs@^1.14.0 || ^2.0.0

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open '/foo/userscripts/package.json'
npm WARN [email protected] requires a peer of qunitjs@^1.14.0 || ^2.0.0 but none was installed.
npm WARN userscripts No description
npm WARN userscripts No repository field.
npm WARN userscripts No README data
npm WARN userscripts No license field.

but...

$ npm list qunitjs -g
/usr/lib
└── [email protected] 

Karma 5.x support

Karma 5 was released recently. Please add support for 5.x version.

Never ending loop when `singlerun: false` and failing test

Hi,

I'm having an issue that I think is dued to karma-qunit.

I created a repo that describes the issue, and you could clone in order to reproduce yourself the problem: karma-qunit-adapter-issue-47.

In a few words:

I use karma, with qunit as testing framework... so I have also installed karma-qunit adapter.

When run the test with singleRun: false and there's at least a failing test, the adapter enters in a never ending loop in which it continues to log the exception (view image).

I am not expert about QUnit internals, however I noticed that when a test fails, QUnit creates an internal test that it uses somehow to track the failing test... karma-qunit executes the testDone callback even for this fake (or better internal) test. I don't know if this is wanted, or necessary, but it seem to be the cause of the never ending log stream.

Do you have any suggestion?

ps. I am using the latest version of all the packages involved (karma, qunitjs, karma-qunit).

"TypeError: toolbar is null" on QUnit v1.17

  • karma-qunit v0.1.4
  • qunitjs v1.17.0

TEST CODE

QUnit.module( "module A", {
    beforeEach: function() {
        // prepare something for all following tests
    },
    afterEach: function() {
        // clean up after each test
    }
});

QUnit.test('some test', function(assert) {
    assert.equal(1, 1);
});

RESULT

TypeError: toolbar is null

QUNIT CODE

function toolbarModuleFilter() {
    var toolbar = id( "qunit-testrunner-toolbar" ), // <= find element.
        moduleFilter = document.createElement( "span" ),
        moduleFilterHtml = toolbarModuleFilterHtml();

    if ( !moduleFilterHtml ) {
        return false;
    }

    moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
    moduleFilter.innerHTML = moduleFilterHtml;

    addEvent( moduleFilter.lastChild, "change", applyUrlParams );

    toolbar.appendChild( moduleFilter ); // <= error!
}

v2.x throws "No tests were run"

Hello.

I tried to update karma-qunit to v2.x along with the necessary switch to qunit instead of qunitjs for Bootstrap.

I always end up with this:


HeadlessChrome 65.0.3325 (Windows 7.0.0) ERROR
  {
    "message": "Uncaught Error: No tests were run.\nat node_modules/qunit/qunit/qunit.js:1248:5\n\nError: No tests were
run.\n    at done (node_modules/qunit/qunit/qunit.js:1248:11)\n    at advanceTestQueue (node_modules/qunit/qunit/qunit.j
s:1144:5)\n    at Object.advance (node_modules/qunit/qunit/qunit.js:1113:5)\n    at begin (node_modules/qunit/qunit/quni
t.js:3126:20)\n    at node_modules/qunit/qunit/qunit.js:3086:6",
    "str": "Uncaught Error: No tests were run.\nat node_modules/qunit/qunit/qunit.js:1248:5\n\nError: No tests were run.
\n    at done (node_modules/qunit/qunit/qunit.js:1248:11)\n    at advanceTestQueue (node_modules/qunit/qunit/qunit.js:11
44:5)\n    at Object.advance (node_modules/qunit/qunit/qunit.js:1113:5)\n    at begin (node_modules/qunit/qunit/qunit.js
:3126:20)\n    at node_modules/qunit/qunit/qunit.js:3086:6"
  }
HeadlessChrome 65.0.3325 (Windows 7.0.0): Executed 0 of 0 ERROR (0.009 secs / 0 secs)
HeadlessChrome 65.0.3325 (Windows 7.0.0): Executed 0 of 0 ERROR (0.013 secs / 0 secs)
.
HeadlessChrome 65.0.3325 (Windows 7.0.0): Executed 1 of 0 ERROR (0.015 secs / 0 secs)
.
HeadlessChrome 65.0.3325 (Windows 7.0.0): Executed 2 of 0 ERROR (0.028 secs / 0 secs)
.
HeadlessChrome 65.0.3325 (Windows 7.0.0): Executed 3 of 0 ERROR (0.046 secs / 0.004 secs)
.
HeadlessChrome 65.0.3325 (Windows 7.0.0): Executed 4 of 0 ERROR (0.077 secs / 0.036 secs)

Going back to the latest karma-qunit 1.x with qunitjs, works fine.

Are we missing something?

/CC @Johann-S

Mark skipped tests correctly

Skipped tests, i.e., tests invoked with qunit.skip('test name', function()....), are not marked as skipped but are listed as passed.

"karma": "^0.13.21",
"karma-chrome-launcher": "^0.2.2",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^0.1.7",
"karma-qunit": "^0.1.9",
"karma-requirejs": "^0.2.5",
"karma-safari-launcher": "^0.1.1",
"karma-verbose-reporter": "0.0.3",
"karma-verbose-summary-reporter": "0.0.1",
"qunitjs": "^1.22.0",

Promise support

There are problems when using the Promise features of qunit:
A failing promise would abort the testsuite but report success with the number of tests passed before the rejecting promise.

qunit.test('rejecting promise test', function() {  
  return Promise.reject();  
});
"karma": "^0.13.21",
"karma-chrome-launcher": "^0.2.2",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^0.1.7",
"karma-qunit": "^0.1.9",
"karma-requirejs": "^0.2.5",
"karma-safari-launcher": "^0.1.1",
"karma-verbose-reporter": "0.0.3",
"karma-verbose-summary-reporter": "0.0.1",
"qunitjs": "^1.22.0",

Autostart from adapter conflicts with autostart from user

I've recently changed my test suite from loading synchronous to loading asynchronous (as a side-effect of a wider change in the delivery application).

As a result, the karma-qunit test is now broken because it has its own asynchronous startup that overrides the one provided by the user.

Both code paths set QUnit.config.autostart = false; and Karma's calls .start() when it is finished, but at that point the user code has only just begun to load and as such QUnit starts the test and also immediately ends the test (as there are 0 pending tests) and Karma shuts down the browser – before any of the tests were run.

INFO [launcher]: Starting browser Chrome
INFO [Chrome 44.0.2403 (Mac OS X 10.10.4)]: Connected on socket BbFAo6lyMsra5CMr3ukt with id 75541682
Chrome 44.0.2403 (Mac OS X 10.10.4): Executed 0 of 0 ERROR (0.001 secs / 0 secs)

JS coding in 2.1.0 when first test fails

JS runtime throws
TypeError: testResult.errors is undefined\nat node_modules/karma-qunit/lib/adapter.js:99
when first test fails.

relevant src code snippet is

runner.log(function (details) {
      if (!details.result) {
        
// ...
        testResult.success = false
        testResult.errors.push(msg) // <- the array.push fails
      }
    })

Environment:
karma-qunit 2.1.0
karma 3.1.1
qUnit 2.6.1
node 11.1.0
macOS 10.14.2

=> I will provide a PR fixing this!

qunit 2.x not usable as a module dependency with karma

If the karma.conf.js is set up to run with the frameworks requirejs and qunit, then qunit will register as a amd module, along with binding to the window.QUnit global. With qunit 1.23.1, it's possible to set up requirejs to load this module, as follows:

in test-main.js:

requirejs.config({
    paths: {
        "qunit": "node_modules/qunitjs/qunit/qunit"
    }
});

and in a foo-test.js:

define([
    'qunit'
], function (
    QUnit
) {
    // normal qunit test goes here
});

However, this works only because both context.js (via karma-qunit adapter.js) and require.js are loading qunit.

After upgrading to qunit 2.1.0, the second attempt to load karma via requirejs fails with an error:

  Error: QUnit has already been defined.
  at node_modules/qunitjs/qunit/qunit.js:2001

The standard approach of preventing context.js from loading qunit so that only requirejs loads it then breaks the qunit-adapter. Ideally, the karma-qunit adapter would detect that requirejs was in use, and switch to using requirejs module loading instead.

Show the qunit ui

It would be nice to have the qunit ui including all assertions and the possibility to rerun separate tests. This could be added to debug.html at runtime, just add the qunit div and the css...

tests from Default Module have unexpected suite information

When executing QUnit test in Default Module

test("test", function () {
  ok(true);
});

BaseReporter.onSpecComplete(browser, result) is called:
result.suite is an array of one element null.
Expected value of result.suite would be an empty array or an array of one string "Default Module"

Problem with path while loading a file for testing

I am the jsartoolkitNFT maintainer and creator, i added in the past qunit test with Grunt but i would use instead Karma with karma-qunit.
JsartoolkitNFT is a small lib for WebAR and it's necessary to load some config parameter files for the set up. I developed some testing to load the camera_para.dat file but i add to 'force' the path to an unusual "./base/tests/camera_para.dat"; normally it's only necessary this path "./camera_para.dat".
Anyway with "./base/tests/camera_para.dat"; the test goes well instead if replace with "./camera_para.dat", tests are failing.
This is my structure in tests folder:

  • camera_para.dat
  • index.html
  • tests.js
    my karma.conf.js file:
// Karma configuration
// Generated on Mon Mar 07 2022 12:03:44 GMT+0100 (Ora standard dell’Europa centrale)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
    frameworks: ['qunit'],

    plugins: [
      'karma-qunit',
      'karma-chrome-launcher'
    ],


    // list of files / patterns to load in the browser
    files: [
      { pattern: 'build/artoolkitNFT.min.js', included: true },
      { pattern: 'tests/*.js', included: true },
      { pattern: 'tests/camera_para.dat', watched: false, included: false, served: true, nocache: false }
    ],


    // list of files / patterns to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
    browsers: [
      //'Firefox', 
      'Chrome', 
      ],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser instances should be started simultaneously
    concurrency: Infinity,

    client: {
      clearContext: false,
      qunit: {
        showUI: true,
        testTimeout: 5000
      }
    }

  })
}

Does it is correct? I have the feeling that i missed something, but searching on the docs can't find anything else.
Thank you,
Walter.

karma-qunit can't resolve qunitjs from github

I want to use qunitjs from the github repository, so I install it like this

$ npm i jquery/qunit
[email protected] node_modules/qunitjs

Then I run karma, and karma-qunit can't resolve the new qunitjs:

$ npm test

> [email protected] test /home/nik/src/dmt
> ./node_modules/karma/bin/karma start

module.js:340
    throw err;
    ^
Error: Cannot find module 'qunitjs'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.require.resolve (module.js:384:19)
    at initQUnit (/home/nik/src/dmt/node_modules/karma-qunit/lib/index.js:7:39)
    at Array.invoke [as 0] (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at get (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:48:43)
    at /home/nik/src/dmt/node_modules/karma/lib/server.js:31:14
    at Array.forEach (native)
    at start (/home/nik/src/dmt/node_modules/karma/lib/server.js:30:21)
    at invoke (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/home/nik/src/dmt/node_modules/karma/lib/server.js:306:12)
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

I'm using npm 1.4.16 and node 0.10.25.

Expected/Actual object values in test failure are reported as [object Object]

Running "karma:main" (karma) task
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 40.0.2214 (Mac OS X 10.9.5)]: Connected on socket 0J5WxWegS9ILUIaPX3Fv with id 3146024
..
Chrome 40.0.2214 (Mac OS X 10.9.5) ve setDomAttributes FAILED
    whitelist affects removal/updating of attributes
    Expected: [object Object]
    Actual: [object Object]
        at Object.<anonymous> (tests/ve.test.js:120:9)
        at Object.Test.run (node_modules/qunitjs/qunit/qunit.js:903:28)
        at node_modules/qunitjs/qunit/qunit.js:1032:11
        at process (node_modules/qunitjs/qunit/qunit.js:591:24)
        at begin (node_modules/qunitjs/qunit/qunit.js:636:2)
        at node_modules/qunitjs/qunit/qunit.js:652:4

................................................................................
................................................................................
...........................
Chrome 40.0.2214 (Mac OS X 10.9.5): Executed 190 of 190 (1 FAILED) (12.644 secs / 12.476 secs)

The HTML page report of QUnit, as well as other tools such as grunt-contrib-qunit use a more sensible stringification.

QUnit 2.0.0 Support

I've tried to install qunitjs 2.0.0 using npm 3.0 to take advantage of the new before and after hooks. However, when trying to do the install I get karma-qunit dependency errors.

Can you confirm qunitjs is compatible with qunitjs 2.0.0 while using NPM version 3.x?

Looking at the karma-qunit package.json, it shows that it does support it, but then there is a peerDependency for ^1.14.

C:\projects\loct\loct\loct-war>npm install [email protected] --savedev
[email protected] C:\projects\loct\loct\loct-war
`-- UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of qunitjs@^1.14.0 but none was installed.
npm WARN [email protected] No repository field.
npm ERR! code 1

C:\projects\loct\loct\loct-war>npm install
npm WARN [email protected] requires a peer of qunitjs@^1.14.0 but none was installed.
npm WARN [email protected] No repository field.

C:\projects\loct\loct\loct-war>npm list
[email protected] C:\projects\loct\loct\loct-war
+-- [email protected] extraneous
`-- UNMET PEER DEPENDENCY [email protected] extraneous

npm ERR! peer dep missing: qunitjs@^1.14.0, required by [email protected]
npm ERR! extraneous: [email protected] C:\projects\loct\loct\loct-war\node_modules\karma-qunit

Thanks,

Brad

karma-qunit doesn't display failing values

karma-qunit does not display failing values for example when using "equal()"

test('int check', function() {
  equal(1, 2, 'unequal ints');
});

results in:

Firefox 23.0.0 (Ubuntu) crypto int check FAILED
    unequal ints
    @/home/jonas/workspace/shufu/spec/test.js:79
    Test.prototype.run@/usr/local/lib/node_modules/karma-qunit/lib/qunit.js:136
    Test.prototype.queue/run/<@/usr/local/lib/node_modules/karma-qunit/lib/qunit.js:279
    process@/usr/local/lib/node_modules/karma-qunit/lib/qunit.js:1277
    QUnit.start/<@/usr/local/lib/node_modules/karma-qunit/lib/qunit.js:383

This is considerable less useful than QUnit's own output:

unequal ints
Expected:   2
Result:     1
Diff:   2 1 
Source:     @file:///home/jonas/workspace/shufu/spec/test.js:79

I am running karma 0.10.2 and karma-qunit that I installed yesterday via npm.

"Adapter did not report total number of specs" error

karma-qunit wants to report the total number of specs on complete, but Karma expects to have this information immediately after the first test is ran. This results in a warning when tests are ran:

WARN [PhantomJS 1.9.7 (Mac OS X)]: Adapter did not report total number of specs.

A workaround is to just tell Karma there are 0 tests, which avoids the warning, but results in "2 of 0 executed" messages.

qunit does not have a mechanism that can provide the total number of tests upfront, so it's not possible to give Karma what it wants. See qunitjs/qunit#350

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.