Registry / testing / web-test-runner-jasmine

web-test-runner-jasmine

JSON →
library0.2.0jsnpmunverified

web-test-runner-jasmine is a plugin designed to integrate the Jasmine testing framework with the Web Test Runner environment, enabling browser-based testing of JavaScript and TypeScript applications using Jasmine's familiar syntax and assertion style. The current stable version is 0.2.0, released recently with fixes for error reporting and logging. While not having a strict release cadence, it receives updates as part of the broader @web ecosystem. Its primary utility lies in providing the `jasmineTestRunnerConfig` function, which simplifies the configuration of Web Test Runner to use Jasmine, handling the necessary setup for running Jasmine specs in a browser context. This package differentiates itself by offering a straightforward way to leverage Jasmine within a modern, browser-centric testing workflow, contrasting with solutions primarily focused on Node.js or older browser environments. It works seamlessly with tools like @web/dev-server-esbuild for TypeScript compilation and @web/test-runner-playwright for browser launching.

npm install web-test-runner-jasmine
INSTALL
IMPORT
SIG · WEB-TEST-RUNNER-JA
W
web-test-runner-jasmine
testingjavascriptv0.2.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.

jasmineTestRunnerConfig
import { jasmineTestRunnerConfig } from 'web-test-runner-jasmine';
const { jasmineTestRunnerConfig } = require('web-test-runner-jasmine');
Web Test Runner configurations primarily use ESM, so `import` syntax in `.mjs` or TypeScript is expected.

This configuration sets up Web Test Runner to use Jasmine, launches a Chromium browser via Playwright, and defines a basic Jasmine test suite for a DOM element.

import { playwrightLauncher } from '@web/test-runner-playwright'; import { esbuildPlugin } from '@web/dev-server-esbuild'; import { jasmineTestRunnerConfig } from 'web-test-runner-jasmine'; // web-test-runner.config.mjs export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({ ...jasmineTestRunnerConfig(), testFramework: { config: { defaultTimeoutInterval: 5000 }, }, nodeResolve: true, files: ['./src/*.spec.js'], browsers: [playwrightLauncher({ product: 'chromium' })], plugins: [esbuildPlugin({ target: 'auto', sourceMap: true })] }); // src/my-component.spec.js describe('a test suite', () => { let element; beforeEach(() => { element = document.createElement('p'); element.innerHTML = 'hello there'; }); afterEach(() => { element.remove(); }); it('should create element', () => { expect(element.innerHTML).toBe('hello there'); }); });
Debug
Known issues
breakingThe package requires Node.js version 24.0.0 or higher. Older Node.js versions are not supported and will result in errors.
fix
Upgrade your Node.js environment to version 24.0.0 or newer. Consider using a Node.js version manager like `nvm` or `volta`.
affects: >=0.1.0
gotchaThis package has a peer dependency on `jasmine-core`. You must install `jasmine-core` separately in your project for `web-test-runner-jasmine` to function correctly.
fix
Install `jasmine-core` alongside `web-test-runner-jasmine`: `npm install --save-dev jasmine-core` or `yarn add -D jasmine-core`.
affects: >=0.1.0
gotchaFor TypeScript projects, you need to install `@types/jasmine` and configure your `tsconfig.json` to include `jasmine` in the `types` array. Additionally, ensure `esbuildPlugin` is configured with `ts: true`.
fix
Install `@types/jasmine`: `npm install --save-dev @types/jasmine`. Then, in `tsconfig.json`, add `"types": ["jasmine"]` under `compilerOptions`. Finally, update `esbuildPlugin({ ts: true, ... })` in your `web-test-runner.config.mjs`.
affects: >=0.1.0
Errors
Common errors & fixes
ReferenceError: describe is not defined
Jasmine global test functions (`describe`, `it`, `expect`) are not correctly exposed in the test environment, typically due to incorrect Web Test Runner or TypeScript configuration.
fix
Ensure `jasmine-core` is installed, `web-test-runner-jasmine` is configured correctly in `web-test-runner.config.mjs`, and for TypeScript, `types: ["jasmine"]` is present in `tsconfig.json` and `@types/jasmine` is installed.
Error: Could not resolve "web-test-runner-jasmine" from ...
Web Test Runner is attempting to import the package using CommonJS `require()` or cannot find the module in an ESM context, or the `web-test-runner.config.mjs` file extension is incorrect.
fix
Verify that your `web-test-runner.config` file uses the `.mjs` extension (e.g., `web-test-runner.config.mjs`) for ESM imports and that `nodeResolve: true` is set in your config.
Error: Cannot find package 'jasmine-core' imported from ...
The peer dependency `jasmine-core` is missing from the project's `node_modules`.
fix
Install `jasmine-core` as a development dependency: `npm install --save-dev jasmine-core` or `yarn add -D jasmine-core`.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
jasmine-corerequiredRequired peer dependency for Jasmine functionality.
Agent activity
17 hits · last 30 days
node
14
Resources
web-test-runner-jasmine — npm install web-test-runner-jasmine · libregistry