Kopia Desk ships with a 31-test suite that exercises every function exported fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Pachanga12/Kopia_Desk_Beta_1/llms.txt
Use this file to discover all available pages before exploring further.
lib/core.js. Because lib/core.js has no Electron dependency — only Node.js built-ins — the entire suite runs with Node’s built-in test runner without installing any additional test framework. Tests create real temporary directories, write real files, and clean up after themselves using the t.after() hook.
Running the Tests
node --test, which automatically discovers test/core.test.js. No configuration file is needed — Node’s test runner finds test files matching the default discovery pattern.
A passing run looks like:
What the Tests Cover
safeName (4 tests)
Verifies that file and folder names are sanitized before use as manifest keys or backup directory names:
- Invalid filesystem characters (
< > : " / \ | ? *and control characters) are replaced with_ - Names longer than 120 characters are truncated
- An all-invalid input (such as
"") never produces an empty string — falls back to"carpeta" - Forward and backslashes are replaced, so the result is always a flat filename segment
safePath (6 tests)
Verifies that path traversal attacks cannot escape the backup destination root before any write operation:
- A valid relative path resolves correctly inside the root
- The resolved path being exactly the root is also accepted
../../Windows/System32style traversal throws with/fuera del disco destino/- A sibling-directory with the same name prefix (
../Backup2/evil.txtwhen root isD:/Backup) is rejected — the check appends a path separator before comparing, so prefix-matching cannot be fooled - Null bytes in the path throw with
/caracteres nulos/ - Empty strings and non-string inputs both throw
Exclusion Filters (3 tests)
CoverscompileExcludePatterns and isExcluded:
- Glob wildcards
*(zero or more characters) and?(exactly one character) are supported - Matching is case-insensitive (
Thumbs.dbmatchesthumbs.db) - Empty strings, whitespace-only strings,
null, andundefinedentries in the pattern array are silently ignored — only valid, non-empty strings produce a compiled regex DEFAULT_EXCLUDESis checked to contain the patterns documented in the README:Thumbs.db,desktop.ini,$RECYCLE.BIN,.git,node_modules,*.tmp
scanDirectoryRecursive (2 tests)
Uses real temporary directories created with fs.mkdtempSync:
- Builds a nested directory tree, places excluded files (
Thumbs.db) and excluded directories (node_modules) alongside regular files, and asserts that only the non-excluded files appear in the returned map - Verifies that each entry in the result map contains the correct
sizeandfullPathproperties - An empty directory returns an empty
{}map without error
hashFileAsync and quickHashFile (4 tests)
quickHashFileproduces the same hash for two files with identical contentquickHashFileproduces different hashes for files with different contentquickHashFileon a file larger than 64 KB reads only the first and last 64 KB — a file whose middle bytes change produces the same quick hash, which the test explicitly documents as a known trade-offhashFileAsynccomputes a full SHA-256 stream hash and returns the expected deterministic hex digest (f3a7a67ab20351ddf47e87ecbf0e5a0868fc0e257d0aea65d018b0405b9a34f3for the string"contenido de prueba")
pickConcurrency (5 tests)
Verifies the disk-type × file-size concurrency heuristic:
| Scenario | Expected concurrency |
|---|---|
| HDD, avg file < 2 MB (many small files) | 2 |
| HDD, avg file ≥ 2 MB (large files) | 1 |
SSD (mediaType: "SSD"), small files | 8 |
NVMe (busType: "NVMe", unknown mediaType), large files | 4 |
| Unknown disk type, small files | 4 |
| Unknown disk type, large files | 2 |
Journal (7 tests)
The journal is an append-only JSONL file written before each copy operation. It records which files were planned and marks each one as done as it completes. If the process is interrupted, the next run detects the leftover journal and cleans up partial files. The tests cover:startJournalreturnsnullwhen the task list is empty (no journal file is created)finishJournaldeletes the journal file when the backup completes without errorspeekJournalsreads pending files and reports the count andlastInterruptedAttimestamp — without deleting the journal or the partial files on diskcheckJournalsdeletes partial files (those not markeddone) and removes the journal — files already markeddoneare preserved- Legacy
.jsonformat — journals written by an older format are still parsed correctly so that old interrupted backups can be cleaned up after upgrading
CI Configuration
Tests run automatically on GitHub Actions on every push and pull request tomaster. The matrix covers Node 20.x and Node 22.x on windows-latest:
CI uses
npm ci --ignore-scripts to skip the Electron binary download (~100 MB). This works because the tests only import lib/core.js, which uses only Node.js built-ins (fs, crypto, child_process, path, util) and has no require("electron") anywhere. The Electron binary is only needed to run npm start or npm run build locally.