File tree Expand file tree Collapse file tree 4 files changed +62
-14
lines changed
Expand file tree Collapse file tree 4 files changed +62
-14
lines changed Original file line number Diff line number Diff line change 5757 shell : bash
5858 run : echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
5959
60- - name : Run tests (node20)
61- if : ${{ matrix.node == '20' }}
62- shell : bash
63- run : npm run test:node20
64-
6560 - name : Run tests
6661 shell : bash
67- if : ${{ matrix.node != '20' }}
6862 run : npm run test:no-build
6963
7064 # Gating job for branch protection.
Original file line number Diff line number Diff line change 11# Instructions
22
3- - use ` npm run build ` to run tsc and test build.
4- - use ` npm run test ` to run tests, run all tests to verify correctness.
5- - use only scripts from ` package.json ` to run commands.
3+ - Use only scripts from ` package.json ` to run commands.
4+ - Use ` npm run build ` to run tsc and test build.
5+ - Use ` npm run test ` to build and run tests, run all tests to verify correctness.
6+ - use ` npm run test path-to-test.ts ` to build and run a single test file, for example, ` npm run test tests/McpContext.test.ts ` .
Original file line number Diff line number Diff line change 1616 "docs:generate" : " node --experimental-strip-types scripts/generate-docs.ts" ,
1717 "start" : " npm run build && node build/src/index.js" ,
1818 "start-debug" : " DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js" ,
19- "test:node20" : " node --import ./build/tests/setup.js --test-reporter spec --test-force-exit --test build/tests" ,
20- "test:no-build" : " node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning --experimental-print-required-tla --test-reporter spec --test-force-exit --test \" build/tests/**/*.test.js\" " ,
2119 "test" : " npm run build && npm run test:no-build" ,
22- "test:only " : " npm run build && npm run test:only:no-build " ,
23- "test:only:no-build " : " node --import ./ build/tests/setup.js --no-warnings=ExperimentalWarning --test-reporter spec -- test-force-exit --test --test- only \" build/tests/**/*.test.js \" " ,
24- "test:update-snapshots" : " npm run build && node --import ./build/tests/setup.js --no-warnings=ExperimentalWarning -- test-force-exit --test --test- update-snapshots \" build/tests/**/*.test.js \" " ,
20+ "test:no-build " : " node scripts/ test.mjs " ,
21+ "test:only" : " npm run build && node scripts/ test.mjs --test- only" ,
22+ "test:update-snapshots" : " npm run build && node scripts/test.mjs --test-update-snapshots" ,
2523 "prepare" : " node --experimental-strip-types scripts/prepare.ts" ,
2624 "verify-server-json-version" : " node --experimental-strip-types scripts/verify-server-json-version.ts"
2725 },
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright 2026 Google LLC
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+ import { spawn } from 'node:child_process' ;
7+ import path from 'node:path' ;
8+ import process from 'node:process' ;
9+
10+ const args = process . argv . slice ( 2 ) ;
11+ const userArgs = args . filter ( arg => ! arg . startsWith ( '-' ) ) ;
12+ const flags = args . filter ( arg => arg . startsWith ( '-' ) ) ;
13+
14+ const files = [ ] ;
15+
16+ if ( userArgs . length > 0 ) {
17+ for ( const arg of userArgs ) {
18+ // Map .ts files to build/ .js files
19+ let testPath = arg ;
20+ if ( testPath . endsWith ( '.ts' ) ) {
21+ testPath = testPath . replace ( / \. t s $ / , '.js' ) ;
22+ if ( ! testPath . startsWith ( 'build/' ) ) {
23+ testPath = path . join ( 'build' , testPath ) ;
24+ }
25+ }
26+ files . push ( testPath ) ;
27+ }
28+ } else {
29+ const isNode20 = process . version . startsWith ( 'v20.' ) ;
30+ if ( isNode20 ) {
31+ files . push ( 'build/tests' ) ;
32+ } else {
33+ files . push ( 'build/tests/**/*.test.js' ) ;
34+ }
35+ }
36+
37+ const nodeArgs = [
38+ '--import' ,
39+ './build/tests/setup.js' ,
40+ '--no-warnings=ExperimentalWarning' ,
41+ '--test-reporter' ,
42+ 'spec' ,
43+ '--test-force-exit' ,
44+ '--test' ,
45+ ...flags ,
46+ ...files ,
47+ ] ;
48+
49+ const child = spawn ( 'node' , nodeArgs , {
50+ stdio : 'inherit' ,
51+ } ) ;
52+
53+ child . on ( 'close' , code => {
54+ process . exit ( code ?? 1 ) ;
55+ } ) ;
You can’t perform that action at this time.
0 commit comments