# Testing

The core library contains code for node and a browser. It also contains UI components that use another testing framework. This document describes how testing works.

## Node Testing

We use Japa to run node tests. Node tests are under `./tests/**/*.spec.ts` directory.

```sh
npm run test:japa
```

## Browser Testing

Most core libraries are also tested in the browser. We use the `@web/test-runner` package to perform these tests. These tests also cover UI and components.

### WTR Limitations

The web test runner requires an interactive mode to run. When using the watch mode we need to run two processes, one for compiling TS in watch mode, and the other to run tests in watch mode. This can't be done using `concurrently` or `wireit` as `concurrently` does not pass keyboard input to the process (perhaps a bug) and `wireit` spins child processes without passing terminal events. There is an [https://github.com/modernweb-dev/web/issues/19](issue report) requesting to allow WTR running in non-interactive mode but for now we need to do this manually.

This means, run the `build:watch` command in one terminal first, and then `test:watch-only` in the other.
