Archived
1
0

Merge pull request #3629 from cdr/jsjoeio/docs-testing

docs(CONTRIBUTING): add section on testing
This commit is contained in:
Joe Previte 2021-06-18 10:04:06 -07:00 committed by GitHub
commit a51836fca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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)
@ -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.