|
1 | 1 | <!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
2 | 2 | <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
| 3 | + |
3 | 4 | # Contributing
|
4 | 5 |
|
5 | 6 | - [Pull Requests](#pull-requests)
|
|
9 | 10 | - [Updating VS Code](#updating-vs-code)
|
10 | 11 | - [Notes about Changes](#notes-about-changes)
|
11 | 12 | - [Build](#build)
|
| 13 | +- [Testing](#testing) |
| 14 | + - [Unit Tests](#unit-tests) |
| 15 | + - [Integration Tests](#integration-tests) |
| 16 | + - [End-to-End Tests](#end-to-end-tests) |
12 | 17 | - [Structure](#structure)
|
13 | 18 | - [Modifications to VS Code](#modifications-to-vs-code)
|
14 | 19 | - [Currently Known Issues](#currently-known-issues)
|
@@ -112,6 +117,43 @@ In our GitHub Actions CI, we use CentOS 7 for maximum compatibility.
|
112 | 117 | If you need your builds to support older distros, run the build commands
|
113 | 118 | inside a Docker container with all the build requirements installed.
|
114 | 119 |
|
| 120 | +## Testing |
| 121 | + |
| 122 | +There are three kinds of tests in code-server: |
| 123 | + |
| 124 | +1. unit tests |
| 125 | +2. integration tests |
| 126 | +3. end-to-end tests |
| 127 | + |
| 128 | +### Unit Tests |
| 129 | + |
| 130 | +Our unit tests are written in TypeScript and run using [Jest](https://jestjs.io/), which is a JavaScript testing framework. |
| 131 | + |
| 132 | +These live under [test/unit](../test/unit). |
| 133 | + |
| 134 | +We use unit tests for functions and things that can be tested in isolation. |
| 135 | + |
| 136 | +### Integration Tests |
| 137 | + |
| 138 | +These are a work-in-progress. We build code-server and run a script called [test-standalone-release.sh`](../ci/build/test-standalone-release.sh) |
| 139 | +which ensures that code-server's CLI is working. |
| 140 | + |
| 141 | +Integration for us means testing things that integrate and rely on each other. For instance, testing the CLI which requires that code-server be built and packaged. |
| 142 | + |
| 143 | +### End-to-End Tests |
| 144 | + |
| 145 | +The end-to-end (e2e) are written in TypeScript and run using [Playwright](https://playwright.dev/). |
| 146 | + |
| 147 | +These live under [test/e2e](../test/e2e). |
| 148 | + |
| 149 | +Before the e2e tests run, we have a `globalSetup` that runs which makes it so you don't have to login before each test and can reuse the authentication state. |
| 150 | + |
| 151 | +Take a look at `codeServer.test.ts` to see how you use it (look at `test.use`). |
| 152 | + |
| 153 | +We also have a model where you can create helpers to use within tests. Take a look at [models/CodeServer.ts](../test/e2e/models/CodeServer.ts) to see an example. |
| 154 | + |
| 155 | +Generally speaking, e2e means testing code-server running in the browser, similar to how a user would interact with it. When running these tests with `yarn test:e2e`, you must have code-server running locally. In CI, this is taken care of for you. |
| 156 | + |
115 | 157 | ## Structure
|
116 | 158 |
|
117 | 159 | The `code-server` script serves an HTTP API for login and starting a remote VS Code process.
|
|
0 commit comments