# Tern plugin

Type `elide test` in a [Tern](https://docs.stencil.so/tern/) terminal and the results draw in the pane as a live
view: totals, each test's status, the failure under the one you select. `elide build`, `elide help`, `elide serve`
and `elide repl` do the same. The [Elide plugin for Tern](https://github.com/elide-dev/tern) adds the rest of a
project workflow: a workspace per `elide.pkl`, a debugger, a source editor with coverage, debug and diagnostics
overlays, a trace waterfall for served apps and a notebook where JavaScript and Python share values.

## Install

**[Install the plugin →](/docs/tern-install)** on macOS on Apple Silicon: check the release, unpack it, run `install.sh`.
With the plugin installed, continue with [the tour](#the-tour).

## See it

Each clip is a recording of the plugin in Tern.

The [Installation](/docs/tern-install) page takes it from here.

## The tour

### Commands become views

Five commands you already type draw native views in any Tern terminal, with no plugin needed. `elide test` and
`elide build` draw inline and stay in scrollback when they finish; `--surface=screen` gives them the whole pane.
`elide help` opens the docs as a page with navigation and search; `elide serve` opens the Server page; `elide repl`
draws an editor with a language picker. Pipe or redirect any of them and you get plain text, as anywhere else.
Details and keys: [Terminal surfaces](/docs/tern-terminal).

### One tab per project

**Open project workspace** turns a directory with `elide.pkl` into a Tern tab: Files, an editor, a terminal in the
project root and a toolbar with **Build project**, **Run tests**, **Run project**, **Debug**, **Source**, **Open
REPL** and **Serve project files**. Test runs are shared: every Tests view of the project, and Tern's agent, see the
same runs. `elide://` links on file names and failure locations open the file at the line.
Details: [Project workspace](/docs/tern-workspace).

### Stop at the failing line

**Debug this test** on the Tests page launches the failing JavaScript or TypeScript test with a breakpoint at its
failure line. In the source editor, `F9` sets a breakpoint, `F5` launches, `F10` and `F11` step, and values are
read when you ask for them. Python sources debug the same way. Details: [Debugging](/docs/tern-debugging).

### Which lines ran

**Run with coverage** (`c`) adds a Coverage tab with line and branch totals, the measured files and `n`/`p` to jump
between uncovered lines. The source editor tints covered, partly covered and uncovered rows while you keep editing.
Details: [Coverage](/docs/tern-coverage).

### Compiler errors as cards

Each javac and kotlinc error, warning and note becomes a card with its source excerpt and an **Open** link. The
source editor marks the line in the gutter, underlines the column and prints the message beside it; `F8` moves to
the next. Details: [Build diagnostics](/docs/tern-build).

### Traces beside the server

`elide serve` in Tern captures the served app's spans and logs locally. Pick a request and read its trace as a
waterfall while your own exporters keep sending to their destinations. Details: [Traces](/docs/tern-telemetry).

### One notebook, several languages

**Open REPL** opens a notebook for JavaScript, Python, Kotlin, CEL and Pkl. Define `const y = {"hi": 5}` in
JavaScript, switch to Python with `Ctrl+L`, and `y.hi` returns `5`. Details: [REPL notebook](/docs/tern-workspace#repl-notebook).

## Palette commands

The plugin's commands are in Tern's command palette under **Elide**.

| Command | Opens |
| --- | --- |
| **Open project workspace** | The workspace for the project around the focused pane. |
| **Project actions** | The project menu. |
| **Run tests** | The Tests page for a project directory or test file you enter. |
| **View project test runs** | The project's recent test runs. |
| **Debug project source** | The debugger on the open source file, or its target picker. |
| **Open Elide source view** | A project file in Elide's source editor. |
| **Open REPL** | A notebook session; **Open js REPL** and **Open python REPL** start in that language. |
| **Serve directory or script** | The Server page for a directory or script you enter. |

## See also

- [Install the Tern plugin](/docs/tern-install) and [Troubleshooting](/docs/tern-troubleshooting)
- [IDE integration](/docs/ide) and the other [editors](/docs/connect-ide)
- [`elide tern`](/docs/cli-references#tern), the command the plugin launches its views with
