Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(CONTRIBUTING): add section on testing #3629

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ VS Code v0.00.0
- chore: update node to v14 #3458 @oxy
- chore: update .gitignore #3557 @cuining
- fix: use sufficient computational effort for password hash #3422 @jsjoeio
- docs(CONTRIBUTING): add section on testing #3629 @jsjoeio

### Development

Expand Down
41 changes: 41 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- [Updating VS Code](#updating-vs-code)
- [Notes about Changes](#notes-about-changes)
- [Build](#build)
- [Testing](#testing)
- [Unit Tests](#unit-tests)
- [Integration Tests](#integration-tests)
- [End-to-End Tests](#end-to-end-tests)
- [Structure](#structure)
- [Modifications to VS Code](#modifications-to-vs-code)
- [Currently Known Issues](#currently-known-issues)
Expand Down Expand Up @@ -112,6 +116,43 @@ In our GitHub Actions CI, we use CentOS 7 for maximum compatibility.
If you need your builds to support older distros, run the build commands
inside a Docker container with all the build requirements installed.

## Testing

There are three kinds of tests in code-server:

1. unit tests
2. integration tests
3. end-to-end tests

### Unit Tests

Our unit tests are written in TypeScript and run using [Jest, the testing framework](https://jestjs.io/).

These live under [test/unit](../test/unit).

We use unit tests for functions and things that can be tested in isolation.

### Integration Tests

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)
which ensures that code-server's CLI is working.

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.

### End-to-End Tests

The end-to-end (e2e) are written in TypeScript and run using [Playwright](https://playwright.dev/).

These live under [test/e2e](../test/e2e).

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.

Take a look at `codeServer.test.ts` to see how you use it (look at `test.use`).

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.

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.

## Structure

The `code-server` script serves an HTTP API for login and starting a remote VS Code process.
Expand Down