From 0df6c4947a5e7425fdec3446fb62a9131ecb01bf Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 5 May 2026 08:26:55 -0400 Subject: [PATCH] chore(test): Performance (#12267) * chore(test): drop no-op per-test Redis flushall The afterEach created a fresh ioredis-mock client and flushed it, which doesn't clear state held by clients elsewhere in the test. Removing the hook saves a few ms across thousands of test cases. * Cache Jest transform cache --- .github/workflows/ci.yml | 20 ++++++++++++++++++-- server/test/setup.ts | 10 ---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 257af95b20..ee77a3af35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,15 @@ jobs: steps: - uses: actions/checkout@v5 - uses: ./.github/actions/install - - run: yarn test:${{ matrix.test-group }} + - name: Restore Jest transform cache + uses: actions/cache@v4 + with: + path: /tmp/jest_runner + key: jest-${{ matrix.test-group }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock', 'app/**/*.ts', 'app/**/*.tsx', 'shared/**/*.ts', 'shared/**/*.tsx') }} + restore-keys: | + jest-${{ matrix.test-group }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock') }}- + jest-${{ matrix.test-group }}- + - run: yarn test:${{ matrix.test-group }} --cacheDirectory=/tmp/jest_runner test-server: needs: changes @@ -110,9 +118,17 @@ jobs: steps: - uses: actions/checkout@v5 - uses: ./.github/actions/install + - name: Restore Jest transform cache + uses: actions/cache@v4 + with: + path: /tmp/jest_runner + key: jest-server-${{ matrix.shard }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock', 'server/**/*.ts', 'shared/**/*.ts', 'plugins/**/*.ts') }} + restore-keys: | + jest-server-${{ matrix.shard }}-${{ hashFiles('.babelrc', '.jestconfig.json', 'yarn.lock') }}- + jest-server-${{ matrix.shard }}- - run: yarn sequelize db:migrate - name: Run server tests - run: yarn test:server --maxWorkers=2 --shard=${{ matrix.shard }}/4 + run: yarn test:server --maxWorkers=2 --shard=${{ matrix.shard }}/4 --cacheDirectory=/tmp/jest_runner bundle-size: needs: changes diff --git a/server/test/setup.ts b/server/test/setup.ts index b015e2f284..9bdea08dbe 100644 --- a/server/test/setup.ts +++ b/server/test/setup.ts @@ -51,16 +51,6 @@ jest.mock("@aws-sdk/s3-request-presigner", () => ({ // Initialize the database models require("@server/storage/database"); -// Import Redis after mocking -const Redis = require("ioredis"); - beforeEach(() => { env.URL = sharedEnv.URL = "https://app.outline.dev"; }); - -afterEach(async () => { - // Create a new Redis instance for cleanup - const redis = new Redis(); - await redis.flushall(); - redis.disconnect(); -});