From bb6b93952c5a7389aea419772eba20006b3559c6 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 23 Sep 2025 09:17:09 +0200 Subject: [PATCH] test: fix shell for windows tests --- .github/workflows/run-tests.yml | 3 +++ package.json | 8 ++++---- tests/setup.ts | 3 ++- tests/tools/screenshot.test.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 47b2e958b..fd144d9d0 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -35,13 +35,16 @@ jobs: node-version: ${{ matrix.node }} - name: Install dependencies + shell: bash run: npm ci - name: Disable AppArmor if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns - name: Run tests + shell: bash run: npm run test # Gating job for branch protection. diff --git a/package.json b/package.json index 5dd92bcda..210813529 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "docs:generate": "node --experimental-strip-types scripts/generate-docs.ts", "start": "npm run build && node build/src/index.js", "start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js", - "test": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test 'build/tests/**/*.test.js'", - "test:only": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'", - "test:only:no-build": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'", - "test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --test-force-exit --test --test-update-snapshots 'build/tests/**/*.test.js'", + "test": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test \"build/tests/**/*.test.js\"", + "test:only": "npm run build && node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"", + "test:only:no-build": "node --require ./build/tests/setup.js --test-reporter spec --test-force-exit --test --test-only \"build/tests/**/*.test.js\"", + "test:update-snapshots": "npm run build && node --require ./build/tests/setup.js --test-force-exit --test --test-update-snapshots \"build/tests/**/*.test.js\"", "prepare": "node --experimental-strip-types scripts/prepare.ts" }, "files": [ diff --git a/tests/setup.ts b/tests/setup.ts index 40ea2b918..b9690a15d 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -4,12 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ import {it} from 'node:test'; +import path from 'node:path'; // This is run by Node when we execute the tests via the --require flag. it.snapshot.setResolveSnapshotPath(testPath => { // By default the snapshots go into the build directory, but we want them // in the tests/ directory. - const correctPath = testPath?.replace('/build/tests', '/tests'); + const correctPath = testPath?.replace(path.join('build', 'tests'), 'tests'); return correctPath + '.snapshot'; }); diff --git a/tests/tools/screenshot.test.ts b/tests/tools/screenshot.test.ts index ec018227f..12d00c7b5 100644 --- a/tests/tools/screenshot.test.ts +++ b/tests/tools/screenshot.test.ts @@ -64,7 +64,7 @@ describe('screenshot', () => { await withBrowser(async (response, context) => { const page = context.getSelectedPage(); await page.setContent( - `
test
`.repeat(5_000), + `
test
`.repeat(7_000), ); await screenshot.handler( {params: {format: 'png', fullPage: true}},