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
muslnode 18–226 runs
build_error
glibcnode 18–226 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
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.
fixUpdate 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.
fixStart 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.
fixVerify 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.
fixUpgrade to `jquery-test-runner` version `0.3.0` or newer, which includes a fix for the `.js` MIME type.
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.