What it does
Paste a few lines of JavaScript, add tests, and press Run. The code runs in a background worker on your device. Each test calls a function by name with the arguments you wrote as JSON and checks the result against the expected JSON. You see pass, fail or error for every test, the actual value, how long it took and everything the code wrote with console.log, formatted the way Node and the browser console format it (nested objects, Map, Set, class names, %s and %o, console.table). Nothing runs when you paste: you have to tick the box and press Run.
What it checks
- Results. A test passes when the returned value, written as JSON, equals the expected JSON. Key order in objects does not matter. When they differ, the first difference is named, such as the item
result[2]that is 4 instead of 3. - Errors. A thrown error shows its name, message and the line in your code where it was thrown. A syntax error shows its message and its line.
- Time, memory and depth. The whole run, including the top-level code and all tests, must finish within the time limit (3 seconds by default, up to 10). When it does not, the engine stops the code, the test that was running is marked as timed out, the tests after it are marked not run, and the worker is ended. Results and console lines that were already produced stay. The page stays responsive. The code may use at most 64 MB of memory, and calls may be nested about 650 deep; beyond that it stops with an error.
- Async code. If a function returns a promise, the tool waits for it and compares the resolved value. A promise that can never finish is reported at once instead of waiting for the time limit.
- Console output follows the rules of Node’s
util.inspectandutil.format, ported to run inside the engine and compared with Node on thousands of values. Up to 200 lines, 2,000 characters per line and 100,000 characters in all. Further output is dropped and the page says so.
What it cannot catch
- It is not a security boundary. The code runs in QuickJS, a separate JavaScript engine compiled to WebAssembly, inside a worker. The code has no access to the page, cookies, files, network or storage. As extra layers, the worker has
fetch,XMLHttpRequest,WebSocket,importScripts,indexedDB,cachesandnavigator.sendBeaconreplaced with functions that throw, the same names throw inside the engine too, and the server sends the worker file with a rule that refuses network connections, nested workers andeval. This is strong isolation, but it is still software: the engine is an older version and may have bugs, and the browser may have too. Do not run code you do not understand. - It is not your browser’s engine. QuickJS (2021) supports classes, async/await, optional chaining, BigInt and regular expression groups. Because it is older than your browser, this tool adds the missing built-ins inside the engine, only when the engine does not have them:
Array.prototype.at,findLast,toSorted,toReversed,with,Object.hasOwn,Object.groupBy,structuredClone, set methods such asunion,Promise.withResolvers,Errorcauses,URL,URLSearchParams,TextEncoder,TextDecoder,atob,btoa,crypto.getRandomValuesandcrypto.randomUUID, and a subset ofIntl(NumberFormat,DateTimeFormat,Collator,PluralRules,ListFormat,RelativeTimeFormat) withtoLocaleString,localeCompareand date parsing that follow the browser’s results. These copies were compared with Node 22 and Chromium on many thousands of inputs, but they are copies: edge cases can still differ. Only theen-USlocale (and the root sort order) is available; other locales and other time zones than UTC and your own give a clear error. Not available at all: the DOM,Intl.Segmenter,Intl.DisplayNames,Atomics, and newer syntax (class static blocks,#field in object, the regular expression flagsdandv,import()); a syntax error says so when it recognises one of them. A test that passes here can still fail in your browser, and the other way round. - Timers use virtual time.
setTimeoutandsetIntervalare provided, but they do not wait: a timer runs as soon as nothing else can run, in the order of its delay.setTimeout(f, 5000)therefore finishes at once.Date.now(),new Date()andperformance.now()move forward with the virtual time, so code that measures how long it waited sees the delay. Timers still waiting after the last test are run, up to 1,000 calls. - Values that are not JSON.
undefined,NaN,Infinity, BigInt, functions, Map, Set and circular objects cannot be written as JSON. They are shown as words and a test that expects a value for them fails with the reason. Leave Expected empty to only run the call. - Not covered. Calling constructors with
new, top-levelawait(wrap it in an async function),importandexport(butmodule.exports = { f, g }is understood, andrequire('util')works; every otherrequiregives a clear message), DOM code, promise rejections that nobody handles (they are not reported), and expecting a function to throw. - One kind of runaway code is stopped late. The engine cannot interrupt a regular expression that backtracks without end. The page waits 0.6 seconds after the time limit and then ends the worker. Nothing is shown for that test except that it timed out. Before the run, the page warns about regular expressions that look like this (a repeated group inside a repeat); that warning is a guess from the text of the code.
- Not a replacement for a test framework. Each run starts a new engine, so nothing is kept between runs. Tests in one run can see each other’s changes to variables.
- Up to 200,000 characters of code, 100 tests, 100,000 characters of arguments per test and 20,000 characters per result.
How to read the results
- Pass means the result equals the expected value. Fail means it was different or could not be compared. Error means the call threw. Timed out means the time limit was reached during this test. Not run means the run ended before this test. Ran means no expected value was given.
- To call a method, write its path:
Math.maxorutil.sum. The function must be defined at the top level of your code (a function, const, let, var or class). - Time is the time the call took, in milliseconds. Virtual timers do not add to it.
Example
The example has a function that adds, one that greets and writes to the console, one that checks even numbers, an async function that uses a timer, and one that fails on null. One test is wrong on purpose so you can see a failure, and one calls the function that fails. The code also contains spin(), an endless loop that is not called. To see the time limit work, add a test for spin, set the limit to 1 second and press Run. Related tools: the Regex Tester runs patterns in a worker too, the JavaScript Formatter tidies code, and the JSON Validator checks the JSON you write as arguments.
Privacy
This tool runs entirely in your browser. The code and the tests are processed on your device and are not sent to a server. The page does not write them to local storage, cookies or the URL. The only network use is loading this site’s own files: the page scripts when the page opens, and the engine files (about 0.7 MB, then cached by your browser; the page checks the engine file against a fingerprint and refuses a damaged or outdated copy) the first time you press Run. Nothing is requested from any other site.
Credits
The engine is QuickJS by Fabrice Bellard and Charlie Gordon, compiled to WebAssembly by quickjs-emscripten 0.23.0 by Jake Teton-Landis. Both are MIT licensed. The licence texts and the origin of the files are in LICENSE-quickjs.txt.