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:
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`
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.
- [./ci/dev/lint.sh](./dev/lint.sh) (`yarn lint`)
- Runs linters.
- [./ci/dev/test.sh](./dev/test.sh) (`yarn test`)
- Runs tests.
- [./ci/dev/test-unit.sh](./dev/test-unit.sh) (`yarn test:unit`)
- 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`)
- Runs `yarn fmt`, `yarn lint` and `yarn test`.
- [./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.
- [./steps/fmt.sh](./steps/fmt.sh)
- Runs `yarn fmt` after ensuring VS Code is patched.
- Runs `yarn fmt`.
- [./steps/lint.sh](./steps/lint.sh)
- Runs `yarn lint` after ensuring VS Code is patched.
- [./steps/test.sh](./steps/test.sh)
- Runs `yarn test` after ensuring VS Code is patched.
- Runs `yarn lint`.
- [./steps/test-unit.sh](./steps/test-unit.sh)
- Runs `yarn test:unit`.
- [./steps/test-e2e.sh](./steps/test-e2e.sh)
- Runs `yarn test:e2e`.
- [./steps/release.sh](./steps/release.sh)
- Runs the release process.
- Generates the npm package at `./release`.

View File

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

View File

@ -3,12 +3,9 @@ set -euo pipefail
main() {
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
# information. We must also run it from the root otherwise coverage will not
# include our source files.
cd "$OLDPWD"
if [[ -z ${PASSWORD-} ]] || [[ -z ${CODE_SERVER_ADDRESS-} ]]; then
echo "The end-to-end testing suites rely on your local environment"
echo -e "\n"
@ -21,7 +18,7 @@ main() {
echo -e "\n"
exit 1
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 "$@"

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 test
yarn test:unit
}
main "$@"

View File

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