Skip to content

Commit 80d3e53

Browse files
authored
chore: add ability to run tests in VSCode UI with Mocha Test Explorer (#2597)
1 parent 3d71822 commit 80d3e53

File tree

55 files changed

+436
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+436
-91
lines changed

.mocharc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"spec": ["testing/dummy.spec.ts"],
3+
"exclude": ["packages/**", "node_modules/**"],
4+
"node-option": ["no-experimental-strip-types=true"]
5+
}

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ MongoDB welcomes community contributions! If you’re interested in making a con
1515
1. Add comments around your new code that explain what's happening
1616
1. Commit and push your changes to your branch then submit a pull request
1717

18+
## Running Tests on VSCode
19+
You can use the `mongosh.code-workspace` file along with the [Mocha Test Explorer](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter) to run and debug tests in VSCode UI.
20+
1821
## Bugs
1922

2023
You can report new bugs by

mongosh.code-workspace

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "mongosh",
5+
"path": "."
6+
},
7+
{
8+
"name": "📦 @mongodb-js/eslint-config-mongosh",
9+
"path": "configs/eslint-config-mongosh"
10+
},
11+
{
12+
"name": "📦 @mongodb-js/tsconfig-mongosh",
13+
"path": "configs/tsconfig-mongosh"
14+
},
15+
{
16+
"name": "📦 @mongosh/docker-build-scripts",
17+
"path": "scripts/docker"
18+
},
19+
{
20+
"name": "📦 @mongosh/async-rewriter2",
21+
"path": "packages/async-rewriter2"
22+
},
23+
{
24+
"name": "📦 @mongosh/build",
25+
"path": "packages/build"
26+
},
27+
{
28+
"name": "📦 @mongosh/errors",
29+
"path": "packages/errors"
30+
},
31+
{
32+
"name": "📦 @mongosh/history",
33+
"path": "packages/history"
34+
},
35+
{
36+
"name": "📦 @mongosh/java-shell",
37+
"path": "packages/java-shell"
38+
},
39+
{
40+
"name": "📦 @mongosh/js-multiline-to-singleline",
41+
"path": "packages/js-multiline-to-singleline"
42+
},
43+
{
44+
"name": "📦 @mongosh/types",
45+
"path": "packages/types"
46+
},
47+
{
48+
"name": "📦 @mongosh/i18n",
49+
"path": "packages/i18n"
50+
},
51+
{
52+
"name": "📦 @mongosh/logging",
53+
"path": "packages/logging"
54+
},
55+
{
56+
"name": "📦 @mongosh/shell-bson",
57+
"path": "packages/shell-bson"
58+
},
59+
{
60+
"name": "📦 @mongosh/arg-parser",
61+
"path": "packages/arg-parser"
62+
},
63+
{
64+
"name": "📦 @mongosh/service-provider-core",
65+
"path": "packages/service-provider-core"
66+
},
67+
{
68+
"name": "📦 @mongosh/service-provider-node-driver",
69+
"path": "packages/service-provider-node-driver"
70+
},
71+
{
72+
"name": "📦 @mongosh/shell-api",
73+
"path": "packages/shell-api"
74+
},
75+
{
76+
"name": "📦 @mongosh/autocomplete",
77+
"path": "packages/autocomplete"
78+
},
79+
{
80+
"name": "📦 @mongosh/shell-evaluator",
81+
"path": "packages/shell-evaluator"
82+
},
83+
{
84+
"name": "📦 @mongosh/snippet-manager",
85+
"path": "packages/snippet-manager"
86+
},
87+
{
88+
"name": "📦 @mongosh/browser-runtime-core",
89+
"path": "packages/browser-runtime-core"
90+
},
91+
{
92+
"name": "📦 @mongosh/editor",
93+
"path": "packages/editor"
94+
},
95+
{
96+
"name": "📦 @mongosh/browser-runtime-electron",
97+
"path": "packages/browser-runtime-electron"
98+
},
99+
{
100+
"name": "📦 @mongosh/cli-repl",
101+
"path": "packages/cli-repl"
102+
},
103+
{
104+
"name": "📦 @mongosh/e2e-tests",
105+
"path": "packages/e2e-tests"
106+
},
107+
{
108+
"name": "📦 mongosh",
109+
"path": "packages/mongosh"
110+
},
111+
{
112+
"name": "📦 @mongosh/node-runtime-worker-thread",
113+
"path": "packages/node-runtime-worker-thread"
114+
},
115+
{
116+
"name": "📦 @mongosh/browser-repl",
117+
"path": "packages/browser-repl"
118+
},
119+
{
120+
"name": "📦 @mongosh/connectivity-tests",
121+
"path": "packages/connectivity-tests"
122+
}
123+
],
124+
"settings": {
125+
"typescript.tsdk": "node_modules/typescript/lib",
126+
"mochaExplorer.configFile": ".mocharc.json",
127+
"mochaExplorer.timeout": 60000,
128+
"mochaExplorer.files": "",
129+
"mochaExplorer.ui": "bdd",
130+
"mochaExplorer.esmLoader": false,
131+
"mochaExplorer.monkeyPatch": true,
132+
"mochaExplorer.autoload": true,
133+
"testExplorer.codeLens": true,
134+
"testExplorer.gutterDecoration": true
135+
},
136+
"extensions": {
137+
"recommendations": [
138+
"hbenl.vscode-mocha-test-adapter"
139+
]
140+
}
141+
}

package-lock.json

Lines changed: 23 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/arg-parser/.mocharc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
3+
"timeout": 60000,
4+
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
5+
"spec": ["./{src,lib}/**/*.spec.ts"],
6+
"exclude": ["**/node_modules/**"]
7+
}

packages/arg-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"unsafe-perm": true
1212
},
1313
"scripts": {
14-
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
14+
"test": "mocha",
1515
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
1616
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
1717
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
3+
"timeout": 60000,
4+
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
5+
"spec": ["./{src,lib}/**/*.spec.ts"],
6+
"exclude": ["**/node_modules/**"]
7+
}

packages/async-rewriter2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"pretest": "npm run compile",
88
"benchmark": "node -r ts-node/register benchmark/index.ts",
9-
"test": "mocha --experimental-vm-modules -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
9+
"test": "mocha --experimental-vm-modules",
1010
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
1111
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
1212
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
3+
"timeout": 60000,
4+
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
5+
"spec": ["./{src,lib}/**/*.spec.ts"],
6+
"exclude": ["**/node_modules/**"]
7+
}

packages/autocomplete/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"node": ">=14.15.1"
1818
},
1919
"scripts": {
20-
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
20+
"test": "mocha",
2121
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
2222
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
2323
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",

0 commit comments

Comments
 (0)