Skip to content

Commit 3e92daa

Browse files
committed
refactor: add scripts to separate unit, e2e tests
1 parent 9869ded commit 3e92daa

File tree

7 files changed

+46
-19
lines changed

7 files changed

+46
-19
lines changed

ci/README.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub)
5252

5353
Currently, we run a command to manually generate the code coverage shield. Follow these steps:
5454

55-
1. Run `yarn test` and make sure all the tests are passing
55+
1. Run `yarn test:unit` and make sure all the tests are passing
5656
2. Run `yarn badges`
5757
3. Go into the README and change the color from `red` to `green` in this line:
5858

@@ -72,8 +72,10 @@ This directory contains scripts used for the development of code-server.
7272
- Runs formatters.
7373
- [./ci/dev/lint.sh](./dev/lint.sh) (`yarn lint`)
7474
- Runs linters.
75-
- [./ci/dev/test.sh](./dev/test.sh) (`yarn test`)
76-
- Runs tests.
75+
- [./ci/dev/test-unit.sh](./dev/test-unit.sh) (`yarn test:unit`)
76+
- Runs unit tests.
77+
- [./ci/dev/test-e2e.sh](./dev/test-e2e.sh) (`yarn test:e2e`)
78+
- Runs end-to-end tests.
7779
- [./ci/dev/ci.sh](./dev/ci.sh) (`yarn ci`)
7880
- Runs `yarn fmt`, `yarn lint` and `yarn test`.
7981
- [./ci/dev/watch.ts](./dev/watch.ts) (`yarn watch`)
@@ -142,11 +144,13 @@ This directory contains the scripts used in CI.
142144
Helps avoid clobbering the CI configuration.
143145

144146
- [./steps/fmt.sh](./steps/fmt.sh)
145-
- Runs `yarn fmt` after ensuring VS Code is patched.
147+
- Runs `yarn fmt`.
146148
- [./steps/lint.sh](./steps/lint.sh)
147-
- Runs `yarn lint` after ensuring VS Code is patched.
148-
- [./steps/test.sh](./steps/test.sh)
149-
- Runs `yarn test` after ensuring VS Code is patched.
149+
- Runs `yarn lint`.
150+
- [./steps/test-unit.sh](./steps/test-unit.sh)
151+
- Runs `yarn test:unit`.
152+
- [./steps/test-e2e.sh](./steps/test-e2e.sh)
153+
- Runs `yarn test:e2e`.
150154
- [./steps/release.sh](./steps/release.sh)
151155
- Runs the release process.
152156
- Generates the npm package at `./release`.

ci/dev/ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main() {
66

77
yarn fmt
88
yarn lint
9-
yarn test
9+
yarn test:unit
1010
}
1111

1212
main "$@"

ci/dev/test.sh renamed to ci/dev/test-e2e.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ set -euo pipefail
33

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

2724
main "$@"

ci/dev/test-unit.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
cd "$(dirname "$0")/../.."
6+
cd test/unit/test-plugin
7+
make -s out/index.js
8+
# We must keep jest in a sub-directory. See ../../test/package.json for more
9+
# information. We must also run it from the root otherwise coverage will not
10+
# include our source files.
11+
cd "$OLDPWD"
12+
CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@"
13+
}
14+
15+
main "$@"

ci/steps/test-e2e.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
cd "$(dirname "$0")/../.."
6+
7+
./release-packages/code-server*-linux-amd64/bin/code-server --home $CODE_SERVER_ADDRESS/healthz &
8+
yarn --frozen-lockfile
9+
yarn test:e2e
10+
}
11+
12+
main "$@"

ci/steps/test.sh renamed to ci/steps/test-unit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main() {
66

77
yarn --frozen-lockfile
88

9-
yarn test
9+
yarn test:unit
1010
}
1111

1212
main "$@"

package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"release:standalone": "./ci/build/build-standalone-release.sh",
1717
"release:github-draft": "./ci/build/release-github-draft.sh",
1818
"release:github-assets": "./ci/build/release-github-assets.sh",
19-
"test:e2e": "./ci/dev/test.sh",
19+
"test:e2e": "./ci/dev/test-e2e.sh",
2020
"test:standalone-release": "./ci/build/test-standalone-release.sh",
21-
"test:unit": "./ci/dev/test.sh",
21+
"test:unit": "./ci/dev/test-unit.sh",
2222
"package": "./ci/build/build-packages.sh",
2323
"postinstall": "./ci/dev/postinstall.sh",
2424
"update:vscode": "./ci/dev/update-vscode.sh",
@@ -125,7 +125,8 @@
125125
"testPathIgnorePatterns": [
126126
"node_modules",
127127
"lib",
128-
"out"
128+
"out",
129+
"test/e2e"
129130
],
130131
"collectCoverage": true,
131132
"collectCoverageFrom": [
@@ -145,8 +146,6 @@
145146
"lines": 40
146147
}
147148
},
148-
"testTimeout": 30000,
149-
"globalSetup": "<rootDir>/test/globalSetup.ts",
150149
"modulePathIgnorePatterns": [
151150
"<rootDir>/lib/vscode",
152151
"<rootDir>/release-packages",
@@ -157,7 +156,7 @@
157156
"<rootDir>/release-images"
158157
],
159158
"moduleNameMapper": {
160-
"^.+\\.(css|less)$": "<rootDir>/test/cssStub.ts"
159+
"^.+\\.(css|less)$": "<rootDir>/test/utils/cssStub.ts"
161160
}
162161
}
163162
}

0 commit comments

Comments
 (0)