Registry / testing / jquery-test-runner

jquery-test-runner

JSON →
library0.3.0jsnpmunverified

The jQuery Test Runner (jtr) is a specialized command-line interface (CLI) tool developed by the jQuery team to execute QUnit test suites across real browsers. It leverages Selenium for browser automation and integrates with BrowserStack for running tests in cloud-based environments. Currently at version 0.3.0, the project shows an active development cadence, with frequent minor releases and bug fixes addressing issues like Selenium driver compatibility (e.g., Safari Technology Preview, IE), console forwarding in JSDOM, and reporting improvements. Its key differentiator is its focus on reliable, real-browser QUnit testing, particularly useful for projects requiring broad browser compatibility testing without relying solely on headless environments.

npm install jquery-test-runner
INSTALL
IMPORT
SIG · JQUERY-TEST-RUNNER
J
jquery-test-runner
testingjavascriptv0.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

run
import { run } from 'jquery-test-runner/lib/commands/run';
const { run } = require('jquery-test-runner');
This refers to an internal command runner function, not typically imported by end-users. Primary interaction is via the `jtr run` CLI command.
createTestServer
import { createTestServer } from 'jquery-test-runner/lib/server';
import createTestServer from 'jquery-test-runner/lib/server';
An internal function for setting up the test server, exposed for advanced tooling or internal testing, not a standard user import. The fix for `.js` MIME type was related to this.
TestRunner
import { TestRunner } from 'jquery-test-runner/lib/testrunner';
const TestRunner = require('jquery-test-runner').TestRunner;
Represents the core test runner class, likely used internally or for highly customized programmatic execution within specific build systems, not typical for direct application use.

This quickstart demonstrates how to run QUnit tests using `jquery-test-runner` via its command-line interface, serving local files and specifying a browser. It outlines basic setup for testing with Chrome, assuming ChromeDriver is available or BrowserStack is configured.

const { spawn } = require('child_process'); const path = require('path'); const fs = require('fs'); // Create a dummy QUnit test file for demonstration const testFilePath = path.join(__dirname, 'tests', 'example.js'); const testHtmlPath = path.join(__dirname, 'tests', 'index.html'); fs.mkdirSync(path.dirname(testFilePath), { recursive: true }); fs.writeFileSync(testFilePath, ` QUnit.module('My Example Module'); QUnit.test('should assert true', function(assert) { assert.ok(true, 'true is truthy'); }); `); fs.writeFileSync(testHtmlPath, ` <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>QUnit Example</title> <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.20.0.css"> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"></div> <script src="https://code.jquery.com/qunit/qunit-2.20.0.js"></script> <script src="example.js"></script> </body> </html> `); console.log('Starting jQuery Test Runner...'); // IMPORTANT: Ensure you have a ChromeDriver installed and in your PATH, // or specify BrowserStack credentials (e.g., via environment variables). // Example for BrowserStack: // process.env.BROWSERSTACK_USERNAME = process.env.BROWSERSTACK_USERNAME ?? ''; // process.env.BROWSERSTACK_ACCESS_KEY = process.env.BROWSERSTACK_ACCESS_KEY ?? ''; const jtrProcess = spawn('jtr', [ 'run', '--url', 'http://localhost:8000/tests/index.html', // URL to your test HTML file '--browser', 'chrome', // Specify the browser to use (e.g., 'chrome', 'firefox', 'safari', 'ie') '--reporters', 'console', '--test-timeout', '30000', // Max time for a test to complete '--serve', '8000', // Serve local files from the current directory on port 8000 '--cwd', __dirname // Set current working directory for file serving ], { stdio: 'inherit' }); jtrProcess.on('close', (code) => { if (code === 0) { console.log('jQuery Test Runner completed successfully.'); } else { console.error(`jQuery Test Runner exited with code ${code}.`); process.exit(1); } // Clean up dummy files fs.rmSync(path.join(__dirname, 'tests'), { recursive: true, force: true }); });
jtr --version
Debug
Known issues
breakingThe `sendTo( console )` method for forwarding console messages in JSDOM environments has been renamed to `forwardTo`. Code relying on the old method will fail.
fix
Update calls from `sendTo( console )` to `forwardTo( console )`.
affects: >=0.2.8
gotchaRunning tests in real browsers via Selenium requires appropriate WebDriver installations (e.g., Chromedriver, Geckodriver) or active cloud service configurations (BrowserStack credentials). Misconfigured drivers or credentials will prevent tests from running.
fix
Ensure WebDriver executables are in your system PATH or correctly configured. Verify BrowserStack `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables are set correctly.
affects: >=0.2.0
gotchaOlder versions might not fully report QUnit global errors. Ensure `jquery-test-runner` is updated for comprehensive reporting.
fix
Upgrade `jquery-test-runner` to version `0.2.4` or newer to include global QUnit errors in the reporter output.
affects: <0.2.4
gotchaSafari Technology Preview support was added in version 0.3.0. If you require testing in STP, you must be on this version or higher.
fix
Upgrade `jquery-test-runner` to version `0.3.0` or newer to enable support for Safari Technology Preview.
affects: <0.3.0
Errors
Common errors & fixes
WebDriverError: session not created: This version of ChromeDriver only supports Chrome version XX
Incompatibility between your installed Chrome browser version and the ChromeDriver version used by Selenium.
fix
Update ChromeDriver to match your Chrome browser version, or update Chrome.
Error: connect ECONNREFUSED 127.0.0.1:4444
Selenium server (WebDriver hub) is not running or is not accessible at the specified address and port.
fix
Start your Selenium WebDriver server or ensure `selenium.host` and `selenium.port` in your configuration are correct.
Error: Could not connect to BrowserStack Local. Please check your network or proxy settings.
BrowserStack Local daemon failed to start or connect, often due to network issues, firewall, or incorrect local setup.
fix
Verify network connectivity, check firewall rules, and ensure BrowserStack Local is correctly installed and configured. Try running `BrowserStackLocal.exe` manually to debug.
MIME type ('text/plain') is not a supported stylesheet MIME type, and stylesheet will be ignored.
Incorrect MIME type served for JavaScript files, preventing browser from executing scripts, particularly in older browsers or strict environments.
fix
Upgrade to `jquery-test-runner` version `0.3.0` or newer, which includes a fix for the `.js` MIME type.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
selenium-webdriverrequiredCore for browser automation via Selenium WebDriver.
browserstack-localoptionalUsed for local testing with BrowserStack services.
qunitrequiredThe specific JavaScript testing framework it is designed to run.
Agent activity
4 hits · last 30 days
node
4
Resources