File tree Expand file tree Collapse file tree 4 files changed +45
-20
lines changed Expand file tree Collapse file tree 4 files changed +45
-20
lines changed Original file line number Diff line number Diff line change 47
47
"watch" : " npm run compile && npm-run-all -p watch:*" ,
48
48
"watch:extension" : " npm run compile:extension -- -watch" ,
49
49
"watch:extension-bundles" : " webpack --mode development --watch" ,
50
- "pretest" : " npm run compile && mongodb-runner start --id=vscode -- --port 27088 " ,
50
+ "pretest" : " npm run compile" ,
51
51
"test" : " npm run test-webview && npm run test-extension" ,
52
52
"test-extension" : " cross-env NODE_OPTIONS=--no-force-async-hooks-checks xvfb-maybe node ./out/test/runTest.js" ,
53
53
"test-webview" : " jest" ,
54
- "posttest" : " mongodb-runner stop --id=vscode" ,
55
54
"analyze-bundle" : " webpack --mode production --analyze" ,
56
55
"vscode:prepublish" : " npm run clean && npm run compile:keyfile && npm run compile:resources && webpack --mode production" ,
57
56
"check" : " npm run lint && npm run depcheck" ,
1067
1066
"mocha-junit-reporter" : " ^2.2.0" ,
1068
1067
"mocha-multi" : " ^1.1.7" ,
1069
1068
"mongodb-client-encryption" : " ^6.0.0" ,
1070
- "mongodb-runner" : " ^5.4.4 " ,
1069
+ "mongodb-runner" : " ^5.4.5 " ,
1071
1070
"node-loader" : " ^0.6.0" ,
1072
1071
"npm-run-all" : " ^4.1.5" ,
1073
1072
"ora" : " ^5.4.1" ,
Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-console */
1
2
import path from 'path' ;
2
3
import { runTests } from '@vscode/test-electron' ;
4
+ import { MongoCluster } from 'mongodb-runner' ;
5
+ import os from 'os' ;
6
+
7
+ import { TEST_DATABASE_PORT } from './suite/dbTestHelper' ;
3
8
4
9
// More information on vscode specific tests: https://github.com/microsoft/vscode-test
5
10
11
+ async function startTestMongoDBServer ( ) {
12
+ console . log ( 'Starting MongoDB server on port' , TEST_DATABASE_PORT ) ;
13
+ return await MongoCluster . start ( {
14
+ topology : 'standalone' ,
15
+ tmpDir : path . join ( os . tmpdir ( ) , 'vscode-test-mongodb-runner' ) ,
16
+ args : [ '--port' , TEST_DATABASE_PORT ] ,
17
+ } ) ;
18
+ }
19
+
6
20
async function main ( ) : Promise < any > {
21
+ const testMongoDBServer = await startTestMongoDBServer ( ) ;
22
+
23
+ let failed = false ;
24
+
7
25
try {
8
26
// The folder containing the Extension Manifest package.json
9
27
// Passed to `--extensionDevelopmentPath`
@@ -25,6 +43,13 @@ async function main(): Promise<any> {
25
43
} catch ( err ) {
26
44
console . error ( 'Failed to run tests:' ) ;
27
45
console . error ( err ) ;
46
+ failed = true ;
47
+ } finally {
48
+ console . log ( 'Stopping MongoDB server on port' , TEST_DATABASE_PORT ) ;
49
+ await testMongoDBServer . close ( ) ;
50
+ }
51
+
52
+ if ( failed ) {
28
53
process . exit ( 1 ) ;
29
54
}
30
55
}
Original file line number Diff line number Diff line change @@ -5,8 +5,9 @@ import type { Document } from 'bson';
5
5
export const TEST_USER_USERNAME = 'testUser' ;
6
6
export const TEST_USER_PASSWORD = 'password' ;
7
7
8
- export const TEST_DATABASE_URI = 'mongodb://localhost:27088' ;
9
- export const TEST_DATABASE_URI_USER = `mongodb://${ TEST_USER_USERNAME } :${ TEST_USER_PASSWORD } @localhost:27088` ;
8
+ export const TEST_DATABASE_PORT = '27088' ;
9
+ export const TEST_DATABASE_URI = `mongodb://localhost:${ TEST_DATABASE_PORT } ` ;
10
+ export const TEST_DATABASE_URI_USER = `mongodb://${ TEST_USER_USERNAME } :${ TEST_USER_PASSWORD } @localhost:${ TEST_DATABASE_PORT } ` ;
10
11
11
12
export const TEST_DB_NAME = 'vscodeTestDatabaseAA' ;
12
13
You can’t perform that action at this time.
0 commit comments