Quokka.js is a rapid prototyping playground in your editor, with access to your project’s files, inline reporting, code coverage and rich output formatting.

Quokka.js is brought to you by the Wallaby.js team and is built on top of the same technology used in the Wallaby.js Core. If you like what you see in Quokka.js and would like the same live features for your unit tests and all files of your project, and a lot more, then definitely check out Wallaby.js.

Getting started

To get started with quokka.js in VS Code, install the extension first by clicking on the Extensions icon in the Activity Bar on the side of VS Code and searching for Quokka. Note that Quokka requires VS Code version 1.10.0 or higher.

To get started with quokka.js in JetBrains IDE, install the plugin first by using Settings - Plugins - Browse repositories and searching for Quokka.

To get started with quokka.js in Atom, install the package first by using Settings - Install and searching for Quokka, or by running the apm install atom-quokka command.

Once the extension is installed, press Ctrl/Cmd + Shift + P to display the editor’s command palette, and then type Quokka to see the list of the available commands. Select and run the New JavaScript File command.

Once the extension is installed, press Ctrl/Cmd + Shift + P to display the editor’s command palette, and then type Quokka to see the list of the available commands. Select and run the Create JavaScript File command.

Once the extension is installed, press Cmd + Shift + N / Ctrl + Alt + Shift + Insert to create a new Quokka file. You may select any JavaScript file type, ECMAScript 6, TypeScript.

Now you are ready to go, just start typing some code in your editor and see what happens next.

Live Feedback

You may create a new Quokka file, or start Quokka on an existing file. The results of the execution are displayed right in the editor. To see the full execution output, you may view the Quokka Console by invoking the Show Output command or clicking the bottom-right status bar indicator.

You may create a new Quokka file, or start Quokka on an existing file by using the Start Quokka context menu action in any opened file editor (you may also assign some shortcut to the action). The results of the execution are displayed right in the editor. To see the full execution output, you may view the Quokka Console by clicking the bottom-right status bar indicator.

If you create a new Quokka scratch file and want to save it, then you may press F5 to do so. Later on, you may open the file and run Quokka using the Start Quokka context menu action in the opened file editor.

It is recommended to memorize a couple of quokka keyboard shortcuts (you may see them when using the editor’s command palette). This way it’ll be much faster.

To open a new quokka file (Cmd/Ctrl + K, J for JavaScript, or Cmd/Ctrl + K, T for TypeScript), to (re)start it on an existing file (Cmd/Ctrl + K, Q).

Live Logging/Compare

You may use console.log or identifier expressions (i.e. just typing a variable name) to log any values.
You may also use sequence expressions to compare objects:

Note that when using identifier expressions for logging (for example, typing a to see the value of the a variable), you may hit some limits in terms of the number of displayed properties and the logged object traversal depth. In this case, you may use console.log(a) to display objects without the limitations.

Live Code Coverage

Once quokka.js is running, you can see the code coverage in the gutter of your editor. The coverage is live, so you can start changing your code and the coverage will automatically be updated, just as you type.

As you may see, there are various colored squares displayed for each line of your source code.

Live Comments

While console.log may do the great job for displaying values, sometimes you may need to see the value right in the middle of an expression. For example, given a chain of a.b().c().d(), you may want to inspect the result of a.b().c() before .d() is called.

The most powerful way to log any expression is to use a special comment right after the expression you want to log.

Inserting the special comment /*?*/ after some expression (or just //? after a statement) will log just the value of that expression.

For example,

a.b()/*?*/.c().d()

will output the result of a.b() expression, and

a.b().c().d() /*?*/
// or just
a.b().c().d() //?

will output the result of the full a.b().c().d() expression.

You may also write any JavaScript code right in the comment to shape the output. The code has the access to the $ variable which is the expression that the comment is appended to. The executed code is within a closure, so it also has the access to any objects that you may access from within the current lexical environment.

Note that there’s no constraints in terms of what the comment code can do. For example, the watch comment below is incrementing d.e value, and returning $, which points to the expression that the comment is appended to (a.b).

Also, unlike console logging, the special comment logging has some built-in smarts. For example, when you place the comment after an expression that is a promise, the resolved value of the promise is logged. Similarly, if an expression is an observable, then its values are displayed. So you don’t need to insert a .then function to just inspect the resolved value of the promise or a forEach/subscribe function to inspect the observable values.

Project Files Import

Quokka ‘Community’ edition allows you to import any locally installed node modules to a Quokka file. In addition to that, Quokka ‘Pro’ edition also allows to import any files from your project:

Quick Package Install

The feature allows to quickly install any node package, via npm or yarn, without switching away from your editor, even without having to type the package name - there is enough information in your code already. The package may be installed just for the active quokka session, so that when you are just playing with things, your node_modules folder is not trashed. Having said that, you may also target the project’s node_modules, if you want to do it.

You may install missing packages via intention actions (Alt+Enter), or via the links in the quokka output.

You may install missing packages by using the hover message, or with the Cmd + K, I keyboard shortcut (whenever there’s a missing package), via command palette (Quokka.js: Install Missing Package ... commands), or via the links in the quokka output.

By default quokka is using the npm install {packageName} command. You may change it to yarn add {packageName} by setting the installPackageCommand value in your quokka config:

{
    "installPackageCommand": "yarn add {packageName}"
}

Live Performance Testing

The feature allows to quickly see how various parts of your code perform. It can be very helpful for identifying possible bottlenecks in your app and for doing the performance optimization, or just for experimenting to see how different things perform.

Inserting the special comment /*?.*/ after any expression will report how much time it took to execute the expression.

Adding the comment to an expression that gets executed multiple times, for example inside a loop, will make the tool to display total execution time, average execution time (total execution time divided by number of times the expression had been executed), minimum and maximum execution time.

Runtime

Quokka.js is using your system’s node.js to run your code. You also may configure quokka to use any specific node.js version, for example if you are using nvm.

To simulate browser environment, you may use this plugin.

Configuration

Quokka.js doesn’t need any configuration by default. It will run your code using your system’s node.js. It may also run your TypeScript code without any configuration, if you are not importing any external TypeScript modules.

If you want like to use Babel/React JSX, or to import other TypeScript files from your project in your Quokka file, or to override tsconfig.json settings, you may configure quokka.js.

Plugins

Quokka.js supports the plugins setting, that allows to specify a file or a node module with some code to execute at various stages of the quokka.js code running workflow. You may also find more information about how to write quokka plugin in the Extensibility docs section.

Examples

Questions and issues

If you found an issue, please report it in our support repository.