Karma jQuery Adapter

0.2.4 · abandoned · verified Sun Apr 19

karma-jquery is a plugin that provides an adapter for integrating the jQuery framework into the Karma test runner environment. It allows tests executed by Karma to have jQuery available globally, facilitating the testing of jQuery-dependent code. The package is extremely old, with its latest version 0.2.4 published 9 years ago, indicating it is no longer actively maintained. This status is further compounded by the official deprecation of the Karma test runner itself as of July 2024, with no new features or general bug fixes planned. While Karma still receives critical security fixes for a limited time, `karma-jquery` is effectively abandoned. Users should consider modern alternatives for JavaScript testing, such as Jest or Web Test Runner, especially since Angular is providing migration paths off Karma.

Common errors

Warnings

Install

Imports

Quickstart

This `karma.conf.js` configuration demonstrates how to install `karma-jquery` and include the 'jquery' framework in a Karma test run, typically alongside a testing framework like Jasmine. This ensures jQuery is available for your tests.

/* karma.conf.js */
module.exports = function(config) {
  config.set({
    // Base path that will be used to resolve all relative paths
    basePath: '',

    // Frameworks to use
    // Available frameworks: https://npmjs.org/browse/keyword/karma-framework
    // 'jquery' MUST be listed AFTER 'jasmine' or 'mocha' if those are used, 
    // as the plugin registers the 'jquery' framework.
    frameworks: ['jasmine', 'jquery'], 

    // List of files / patterns to load in the browser
    files: [
      // Assuming your tests rely on jQuery
      'path/to/your/jquery-dependent-code.js',
      'path/to/your/tests.js'
    ],

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

    // Preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {},

    // Test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/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://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

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

    // Concurrency level
    // How many browser should be started simultaneously
    concurrency: Infinity
  });
};

view raw JSON →