Registry / testing / webtorrent-fixtures

webtorrent-fixtures

JSON →
library2.0.3jsnpmunverified

Provides sample torrent files and content for testing WebTorrent-based applications. Current version 2.0.3, released on npm with a mature and stable API. Includes common torrent fixtures (e.g., 'leaves' torrent with its content) and metadata. No major release cadence; maintained as part of the WebTorrent ecosystem. Key differentiator: standardized, ready-to-use torrent test data with known infohashes and file structures, eliminating the need to generate test fixtures manually.

npm install webtorrent-fixtures
INSTALL
IMPORT
SIG · WEBTORRENT-FIXTURE
W
webtorrent-fixtures
testingjavascriptv2.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import fixtures from 'webtorrent-fixtures'
const fixtures = require('webtorrent-fixtures')
ESM-only package; do not use CommonJS require.
leaves
import { leaves } from 'webtorrent-fixtures'
const { leaves } = require('webtorrent-fixtures')
Named exports available; prefer destructuring for individual fixtures.
leavesContent
import { leavesContent } from 'webtorrent-fixtures'
Exported as Buffer; useful for testing file content.

Shows how to import the fixtures and use them with WebTorrent to start downloading and accessing content.

import fixtures from 'webtorrent-fixtures' import WebTorrent from 'webtorrent' const client = new WebTorrent() client.add(fixtures.leaves.torrent, { path: '/tmp/webtorrent' }, (torrent) => { torrent.files.forEach((file) => { file.getBuffer((err, buf) => { if (err) throw err console.log('Downloaded buffer length:', buf.length) }) }) })
Debug
Known issues
breakingESM-only: This package no longer supports CommonJS require().
fix
Use import statements instead of require()
affects: >=2.0.0
deprecatedfixtures.leaves.torrent is the correct way to access torrent buffer; older examples may use .torrent_file (removed).
fix
Use .torrent property
affects: >=2.0.0
gotchado not modify exported objects; they are shared across tests and may cause side effects.
fix
Deep-clone if mutation is required.
affects: all
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using require() to import an ESM-only package
fix
Replace const fixtures = require('webtorrent-fixtures') with import fixtures from 'webtorrent-fixtures'
TypeError: fixtures.leaves.torrent_file is undefined
.torrent_file property removed in v2
fix
Use .torrent instead
Cannot read properties of undefined (reading 'torrent')
Import not resolved or module not installed
fix
Run npm install webtorrent-fixtures
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
Resources
webtorrent-fixtures — npm install webtorrent-fixtures · libregistry