Skip to content

Commit 08fc6dc

Browse files
authored
test: stabilize CI integration tests (#78)
* test: isolate BUILD_ID prefix test by copying app to temp dir and linking local package * test: add delay before TTL check to ensure background sync completes * test: allow non-frozen install in temp build-id integration app * ci: split build-id integration test into dedicated job
1 parent 7947efd commit 08fc6dc

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
run: cd test/integration/${{ matrix.next-test-app }} && pnpm build
7777

7878
- name: Run tests
79-
run: pnpm test
79+
run: pnpm test:ci
8080
env:
8181
SKIP_BUILD: true
8282
NEXT_TEST_APP: ${{ matrix.next-test-app }}
@@ -121,3 +121,50 @@ jobs:
121121
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # NPM token for publishing
122122
run: |
123123
npx semantic-release --dry-run
124+
125+
build-id-prefix:
126+
runs-on: ubuntu-latest
127+
permissions:
128+
contents: read
129+
steps:
130+
- name: Checkout code
131+
uses: actions/checkout@v6
132+
133+
- name: Install pnpm
134+
run: corepack enable
135+
136+
- name: Setup Node.js
137+
uses: actions/setup-node@v6
138+
with:
139+
node-version: '22'
140+
cache: 'pnpm'
141+
142+
- name: Install dependencies
143+
run: pnpm install --ignore-scripts
144+
145+
- name: Run lint
146+
run: pnpm lint
147+
148+
- name: Build project
149+
run: pnpm build
150+
151+
- name: Start Redis
152+
uses: supercharge/redis-github-action@1.8.0
153+
with:
154+
redis-version: '7'
155+
redis-port: 6379
156+
157+
- name: Install redis-cli
158+
run: sudo apt-get update && sudo apt-get install -y redis-tools
159+
160+
- name: Configure Redis Keyspace Notifications
161+
run: redis-cli config set notify-keyspace-events Exe
162+
163+
- name: Install Integration Test Project
164+
run: cd test/integration/next-app-15-4-7 && pnpm install
165+
166+
- name: Build Integration Test Project
167+
run: cd test/integration/next-app-15-4-7 && pnpm build
168+
169+
- name: Run BUILD_ID integration test
170+
run: pnpm test:integration:build-id-prefix

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ To run all tests you can use the following command:
226226
pnpm build && pnpm test
227227
```
228228

229+
For CI, we use dedicated scripts:
230+
231+
```bash
232+
pnpm test:ci
233+
pnpm test:integration:build-id-prefix
234+
```
235+
229236
Folder layout / runners:
230237

231238
- **Vitest** (unit + integration) lives in `src/**/*.test.ts(x)` and `test/**`.
@@ -248,6 +255,12 @@ To run integration tests you can use the following command:
248255
pnpm build && pnpm test:integration
249256
```
250257

258+
To run the BUILD_ID integration test independently:
259+
260+
```bash
261+
pnpm build && pnpm test:integration:build-id-prefix
262+
```
263+
251264
### E2E tests (Playwright)
252265

253266
To run Playwright tests (`tests/**`) you can use:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"lint": "eslint -c eslint.config.mjs --fix",
1717
"format": "prettier --write 'src/**/*.ts' 'src/*.ts'",
1818
"test": "vitest --coverage --config vite.config.ts",
19+
"test:ci": "vitest --run --coverage --config vite.config.ts src/**/*.test.ts src/**/*.test.tsx test/integration/nextjs-cache-handler.integration.test.ts",
20+
"test:integration:build-id-prefix": "vitest --run --coverage --config vite.config.ts test/integration/build-id-prefix.integration.test.ts",
1921
"test:ui": "vitest --ui --config vite.config.ts",
2022
"test:unit": "vitest --config vite.config.ts src/**/*.test.ts src/**/*.test.tsx",
2123
"test:integration": "vitest --config vite.config.ts ./test/integration/nextjs-cache-handler.integration.test.ts",

test/integration/nextjs-cache-handler.integration.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ describe('Next.js Turbo Redis Cache Integration', () => {
618618
});
619619

620620
it('Redis should have a key for the page which should have a TTL set to 28 days (2 * 14 days default revalidate time)', async () => {
621+
await delay(REDIS_BACKGROUND_SYNC_DELAY);
621622
// check Redis keys
622623
const ttl = await redisClient.ttl(
623624
process.env.VERCEL_URL + '/pages/no-fetch/default-page',

0 commit comments

Comments
 (0)