Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"spec": ["testing/dummy.spec.ts"],
"exclude": ["packages/**", "node_modules/**"],
"node-option": ["no-experimental-strip-types=true"]
}
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ MongoDB welcomes community contributions! If you’re interested in making a con
1. Add comments around your new code that explain what's happening
1. Commit and push your changes to your branch then submit a pull request

## Running Tests on VSCode
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.

## Bugs

You can report new bugs by
Expand Down
141 changes: 141 additions & 0 deletions mongosh.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"folders": [
{
"name": "mongosh",
"path": "."
},
{
"name": "📦 @mongodb-js/eslint-config-mongosh",
"path": "configs/eslint-config-mongosh"
},
{
"name": "📦 @mongodb-js/tsconfig-mongosh",
"path": "configs/tsconfig-mongosh"
},
{
"name": "📦 @mongosh/docker-build-scripts",
"path": "scripts/docker"
},
{
"name": "📦 @mongosh/async-rewriter2",
"path": "packages/async-rewriter2"
},
{
"name": "📦 @mongosh/build",
"path": "packages/build"
},
{
"name": "📦 @mongosh/errors",
"path": "packages/errors"
},
{
"name": "📦 @mongosh/history",
"path": "packages/history"
},
{
"name": "📦 @mongosh/java-shell",
"path": "packages/java-shell"
},
{
"name": "📦 @mongosh/js-multiline-to-singleline",
"path": "packages/js-multiline-to-singleline"
},
{
"name": "📦 @mongosh/types",
"path": "packages/types"
},
{
"name": "📦 @mongosh/i18n",
"path": "packages/i18n"
},
{
"name": "📦 @mongosh/logging",
"path": "packages/logging"
},
{
"name": "📦 @mongosh/shell-bson",
"path": "packages/shell-bson"
},
{
"name": "📦 @mongosh/arg-parser",
"path": "packages/arg-parser"
},
{
"name": "📦 @mongosh/service-provider-core",
"path": "packages/service-provider-core"
},
{
"name": "📦 @mongosh/service-provider-node-driver",
"path": "packages/service-provider-node-driver"
},
{
"name": "📦 @mongosh/shell-api",
"path": "packages/shell-api"
},
{
"name": "📦 @mongosh/autocomplete",
"path": "packages/autocomplete"
},
{
"name": "📦 @mongosh/shell-evaluator",
"path": "packages/shell-evaluator"
},
{
"name": "📦 @mongosh/snippet-manager",
"path": "packages/snippet-manager"
},
{
"name": "📦 @mongosh/browser-runtime-core",
"path": "packages/browser-runtime-core"
},
{
"name": "📦 @mongosh/editor",
"path": "packages/editor"
},
{
"name": "📦 @mongosh/browser-runtime-electron",
"path": "packages/browser-runtime-electron"
},
{
"name": "📦 @mongosh/cli-repl",
"path": "packages/cli-repl"
},
{
"name": "📦 @mongosh/e2e-tests",
"path": "packages/e2e-tests"
},
{
"name": "📦 mongosh",
"path": "packages/mongosh"
},
{
"name": "📦 @mongosh/node-runtime-worker-thread",
"path": "packages/node-runtime-worker-thread"
},
{
"name": "📦 @mongosh/browser-repl",
"path": "packages/browser-repl"
},
{
"name": "📦 @mongosh/connectivity-tests",
"path": "packages/connectivity-tests"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ./scripts/sort-workspaces also update this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea

],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib",
"mochaExplorer.configFile": ".mocharc.json",
"mochaExplorer.timeout": 60000,
"mochaExplorer.files": "",
"mochaExplorer.ui": "bdd",
"mochaExplorer.esmLoader": false,
"mochaExplorer.monkeyPatch": true,
"mochaExplorer.autoload": true,
"testExplorer.codeLens": true,
"testExplorer.gutterDecoration": true
},
"extensions": {
"recommendations": [
"hbenl.vscode-mocha-test-adapter"
]
}
}
69 changes: 23 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/arg-parser/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 60000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./{src,lib}/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
2 changes: 1 addition & 1 deletion packages/arg-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"unsafe-perm": true
},
"scripts": {
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
"test": "mocha",
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Expand Down
7 changes: 7 additions & 0 deletions packages/async-rewriter2/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 60000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./{src,lib}/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
2 changes: 1 addition & 1 deletion packages/async-rewriter2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"pretest": "npm run compile",
"benchmark": "node -r ts-node/register benchmark/index.ts",
"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\"",
"test": "mocha --experimental-vm-modules",
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Expand Down
7 changes: 7 additions & 0 deletions packages/autocomplete/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 60000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./{src,lib}/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
2 changes: 1 addition & 1 deletion packages/autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"node": ">=14.15.1"
},
"scripts": {
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
"test": "mocha",
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Expand Down
7 changes: 7 additions & 0 deletions packages/browser-repl/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 60000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./{src,lib}/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
16 changes: 10 additions & 6 deletions packages/browser-repl/src/iframe-runtime/iframe-runtime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import type { ServiceProvider } from '@mongosh/service-provider-core';
import * as bson from 'bson';

describe('IframeRuntime', function () {
let runtime;
let serviceProvider;
let runtime: IframeRuntime;
let serviceProvider: ServiceProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💙


beforeEach(function () {
document.body.innerHTML = '';
serviceProvider = { bsonLibrary: bson };
serviceProvider = { bsonLibrary: bson } as unknown as ServiceProvider;
runtime = new IframeRuntime(serviceProvider);
});

Expand All @@ -21,8 +21,10 @@ describe('IframeRuntime', function () {

const iframe = document.querySelector('iframe');
expect(iframe).to.exist;
expect(iframe.style.display).to.equal('none');
expect(iframe.sandbox.value).to.equal('allow-same-origin');
expect((iframe as HTMLIFrameElement).style.display).to.equal('none');
expect((iframe as HTMLIFrameElement).sandbox.value).to.equal(
'allow-same-origin'
);
});
});

Expand All @@ -47,7 +49,9 @@ describe('IframeRuntime', function () {
});

it('does not interfere with other instances', async function () {
const other = new IframeRuntime({ bsonLibrary: bson } as ServiceProvider);
const other = new IframeRuntime({
bsonLibrary: bson,
} as unknown as ServiceProvider);
await runtime.evaluate('x = 1');
await other.evaluate('x = 2');

Expand Down
7 changes: 7 additions & 0 deletions packages/browser-runtime-core/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 60000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./{src,lib}/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
2 changes: 1 addition & 1 deletion packages/browser-runtime-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "git://github.com/mongodb-js/mongosh.git"
},
"scripts": {
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
"test": "mocha",
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Expand Down
7 changes: 7 additions & 0 deletions packages/browser-runtime-electron/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 60000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./{src,lib}/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
2 changes: 1 addition & 1 deletion packages/browser-runtime-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "git://github.com/mongodb-js/mongosh.git"
},
"scripts": {
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\" --reporter \"../../configs/mocha-config-mongosh/reporter.ts\"",
"test": "mocha",
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
Expand Down
7 changes: 7 additions & 0 deletions packages/build/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": ["../../scripts/import-expansions.js", "ts-node/register"],
"timeout": 30000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./src/**/*.spec.ts"],
"exclude": ["**/node_modules/**"]
}
Loading
Loading