Skip to content

Commit 3d790a8

Browse files
authored
[server] enhanced mocha setups (#18390)
1 parent f911008 commit 3d790a8

File tree

7 files changed

+30
-54
lines changed

7 files changed

+30
-54
lines changed

.gitpod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@ vscode:
8282
- dbaeumer.vscode-eslint
8383
- esbenp.prettier-vscode
8484
- akosyakov.gitpod-monitor
85+
- hbenl.vscode-mocha-test-adapter

components/gitpod-db/src/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Config {
1515
// defaults to be used only in tests
1616
const dbSetup: DatabaseConfig = {
1717
host: process.env.DB_HOST || "localhost",
18-
port: getEnvVarParsed("DB_PORT", Number.parseInt, "3306"),
18+
port: getEnvVarParsed("DB_PORT", Number.parseInt, "23306"),
1919
username: process.env.DB_USERNAME || "gitpod",
2020
password: process.env.DB_PASSWORD || "test",
2121
database: process.env.DB_NAME || "gitpod",
@@ -50,7 +50,10 @@ export class Config {
5050
}
5151

5252
get dbEncryptionKeys(): string {
53-
return getEnvVar("DB_ENCRYPTION_KEYS");
53+
return getEnvVar(
54+
"DB_ENCRYPTION_KEYS",
55+
`[{"name":"general","version":1,"primary":true,"material":"5vRrp0H4oRgdkPnX1qQcS54Q0xggr6iyho42IQ1rO+c="}]`,
56+
);
5457
}
5558
}
5659

components/server/.vscode/launch.json

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"mochaExplorer.files": [
3+
"dist/**/*.spec.js",
4+
"dist/**/*.spec.db.js"
5+
],
6+
"mochaExplorer.require": [
7+
"source-map-support/register",
8+
"reflect-metadata/Reflect"
9+
],
10+
"mochaExplorer.watch": [
11+
"dist/**/*.spec.js",
12+
"dist/**/*.spec.db.js"
13+
],
14+
"mochaExplorer.exit": true,
15+
"mochaExplorer.timeout": 60000
16+
}

components/server/BUILD.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ packages:
33
type: yarn
44
srcs:
55
- "src/**"
6-
- "typings/**"
76
- "test/**"
87
- .eslintrc
98
- package.json
@@ -24,6 +23,10 @@ packages:
2423
packaging: offline-mirror
2524
yarnLock: ${coreYarnLockBase}/yarn.lock
2625
tsconfig: tsconfig.json
26+
commands:
27+
# leeway executes the build and test step in the wrong order, so we have to switch them here
28+
test: ["yarn", "build"]
29+
build: ["yarn", "test"]
2730
- name: docker
2831
type: docker
2932
deps:

components/server/mocha.opts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
--require ts-node/register
21
--require reflect-metadata/Reflect
32
--require source-map-support/register
43
--reporter spec
5-
--watch-extensions ts
6-
--exit
4+
--watch-extensions js
5+
--exit

components/server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"clean:node": "rimraf node_modules",
1919
"purge": "yarn clean && yarn clean:node && yarn run rimraf yarn.lock",
2020
"test": "cleanup() { echo 'Cleanup started'; yarn stop-services; }; trap cleanup EXIT; yarn test:unit && yarn start-services && yarn test:db",
21-
"test:unit": "TS_NODE_FILES=true mocha --opts mocha.opts './**/*.spec.ts' --exclude './node_modules/**'",
22-
"test:db": ". $(leeway run components/gitpod-db:db-test-env) && TS_NODE_FILES=true mocha --opts mocha.opts './**/*.spec.db.ts' --exclude './node_modules/**'",
21+
"test:unit": "mocha --opts mocha.opts './**/*.spec.js' --exclude './node_modules/**'",
22+
"test:db": ". $(leeway run components/gitpod-db:db-test-env) && mocha --opts mocha.opts './**/*.spec.db.js' --exclude './node_modules/**'",
2323
"start-services": "yarn start-testdb && yarn start-redis && yarn start-spicedb",
2424
"stop-services": "yarn stop-redis && yarn stop-spicedb",
2525
"start-testdb": "if netstat -tuln | grep ':23306 '; then echo 'Mysql is already running.'; else leeway run components/gitpod-db:init-testdb; fi",

0 commit comments

Comments
 (0)