refactor: add scripts to separate unit, e2e tests

This commit is contained in:
Joe Previte 2021-03-09 16:35:25 -07:00
parent d10da3f7c3
commit 529d69e8e8
No known key found for this signature in database
GPG Key ID: 2C91590C6B742C24
7 changed files with 46 additions and 19 deletions

View File

@ -52,7 +52,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub)
Currently, we run a command to manually generate the code coverage shield. Follow these steps: Currently, we run a command to manually generate the code coverage shield. Follow these steps:
1. Run `yarn test` and make sure all the tests are passing 1. Run `yarn test:unit` and make sure all the tests are passing
2. Run `yarn badges` 2. Run `yarn badges`
3. Go into the README and change the color from `red` to `green` in this line: 3. Go into the README and change the color from `red` to `green` in this line:
@ -72,8 +72,10 @@ This directory contains scripts used for the development of code-server.
- Runs formatters. - Runs formatters.
- [./ci/dev/lint.sh](./dev/lint.sh) (`yarn lint`) - [./ci/dev/lint.sh](./dev/lint.sh) (`yarn lint`)
- Runs linters. - Runs linters.
- [./ci/dev/test.sh](./dev/test.sh) (`yarn test`) - [./ci/dev/test-unit.sh](./dev/test-unit.sh) (`yarn test:unit`)
- Runs tests. - Runs unit tests.
- [./ci/dev/test-e2e.sh](./dev/test-e2e.sh) (`yarn test:e2e`)
- Runs end-to-end tests.
- [./ci/dev/ci.sh](./dev/ci.sh) (`yarn ci`) - [./ci/dev/ci.sh](./dev/ci.sh) (`yarn ci`)
- Runs `yarn fmt`, `yarn lint` and `yarn test`. - Runs `yarn fmt`, `yarn lint` and `yarn test`.
- [./ci/dev/watch.ts](./dev/watch.ts) (`yarn watch`) - [./ci/dev/watch.ts](./dev/watch.ts) (`yarn watch`)
@ -142,11 +144,13 @@ This directory contains the scripts used in CI.
Helps avoid clobbering the CI configuration. Helps avoid clobbering the CI configuration.
- [./steps/fmt.sh](./steps/fmt.sh) - [./steps/fmt.sh](./steps/fmt.sh)
- Runs `yarn fmt` after ensuring VS Code is patched. - Runs `yarn fmt`.
- [./steps/lint.sh](./steps/lint.sh) - [./steps/lint.sh](./steps/lint.sh)
- Runs `yarn lint` after ensuring VS Code is patched. - Runs `yarn lint`.
- [./steps/test.sh](./steps/test.sh) - [./steps/test-unit.sh](./steps/test-unit.sh)
- Runs `yarn test` after ensuring VS Code is patched. - Runs `yarn test:unit`.
- [./steps/test-e2e.sh](./steps/test-e2e.sh)
- Runs `yarn test:e2e`.
- [./steps/release.sh](./steps/release.sh) - [./steps/release.sh](./steps/release.sh)
- Runs the release process. - Runs the release process.
- Generates the npm package at `./release`. - Generates the npm package at `./release`.

View File

@ -6,7 +6,7 @@ main() {
yarn fmt yarn fmt
yarn lint yarn lint
yarn test yarn test:unit
} }
main "$@" main "$@"

View File

@ -3,12 +3,9 @@ set -euo pipefail
main() { main() {
cd "$(dirname "$0")/../.." cd "$(dirname "$0")/../.."
cd test/test-plugin
make -s out/index.js
# We must keep jest in a sub-directory. See ../../test/package.json for more # We must keep jest in a sub-directory. See ../../test/package.json for more
# information. We must also run it from the root otherwise coverage will not # information. We must also run it from the root otherwise coverage will not
# include our source files. # include our source files.
cd "$OLDPWD"
if [[ -z ${PASSWORD-} ]] || [[ -z ${CODE_SERVER_ADDRESS-} ]]; then if [[ -z ${PASSWORD-} ]] || [[ -z ${CODE_SERVER_ADDRESS-} ]]; then
echo "The end-to-end testing suites rely on your local environment" echo "The end-to-end testing suites rely on your local environment"
echo -e "\n" echo -e "\n"
@ -21,7 +18,7 @@ main() {
echo -e "\n" echo -e "\n"
exit 1 exit 1
fi fi
CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --config ./test/jest.e2e.config.ts
} }
main "$@" main "$@"

15
ci/dev/test-unit.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
main() {
cd "$(dirname "$0")/../.."
cd test/unit/test-plugin
make -s out/index.js
# We must keep jest in a sub-directory. See ../../test/package.json for more
# information. We must also run it from the root otherwise coverage will not
# include our source files.
cd "$OLDPWD"
CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@"
}
main "$@"

12
ci/steps/test-e2e.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
main() {
cd "$(dirname "$0")/../.."
./release-packages/code-server*-linux-amd64/bin/code-server --home $CODE_SERVER_ADDRESS/healthz &
yarn --frozen-lockfile
yarn test:e2e
}
main "$@"

View File

@ -6,7 +6,7 @@ main() {
yarn --frozen-lockfile yarn --frozen-lockfile
yarn test yarn test:unit
} }
main "$@" main "$@"

View File

@ -16,9 +16,9 @@
"release:standalone": "./ci/build/build-standalone-release.sh", "release:standalone": "./ci/build/build-standalone-release.sh",
"release:github-draft": "./ci/build/release-github-draft.sh", "release:github-draft": "./ci/build/release-github-draft.sh",
"release:github-assets": "./ci/build/release-github-assets.sh", "release:github-assets": "./ci/build/release-github-assets.sh",
"test:e2e": "./ci/dev/test.sh", "test:e2e": "./ci/dev/test-e2e.sh",
"test:standalone-release": "./ci/build/test-standalone-release.sh", "test:standalone-release": "./ci/build/test-standalone-release.sh",
"test:unit": "./ci/dev/test.sh", "test:unit": "./ci/dev/test-unit.sh",
"package": "./ci/build/build-packages.sh", "package": "./ci/build/build-packages.sh",
"postinstall": "./ci/dev/postinstall.sh", "postinstall": "./ci/dev/postinstall.sh",
"update:vscode": "./ci/dev/update-vscode.sh", "update:vscode": "./ci/dev/update-vscode.sh",
@ -126,7 +126,8 @@
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"node_modules", "node_modules",
"lib", "lib",
"out" "out",
"test/e2e"
], ],
"collectCoverage": true, "collectCoverage": true,
"collectCoverageFrom": [ "collectCoverageFrom": [
@ -146,8 +147,6 @@
"lines": 40 "lines": 40
} }
}, },
"testTimeout": 30000,
"globalSetup": "<rootDir>/test/globalSetup.ts",
"modulePathIgnorePatterns": [ "modulePathIgnorePatterns": [
"<rootDir>/lib/vscode", "<rootDir>/lib/vscode",
"<rootDir>/release-packages", "<rootDir>/release-packages",
@ -158,7 +157,7 @@
"<rootDir>/release-images" "<rootDir>/release-images"
], ],
"moduleNameMapper": { "moduleNameMapper": {
"^.+\\.(css|less)$": "<rootDir>/test/cssStub.ts" "^.+\\.(css|less)$": "<rootDir>/test/utils/cssStub.ts"
} }
} }
} }