Skip to content

Commit 0dbd33e

Browse files
committed
[CI] Add node.js integration tests
1 parent 794cf4d commit 0dbd33e

File tree

11 files changed

+3394
-0
lines changed

11 files changed

+3394
-0
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,43 @@ jobs:
140140
env:
141141
BIGQUERY_EMULATOR_REPOSITORY: bigquery-emulator
142142
BIGQUERY_EMULATOR_VERSION: test
143+
144+
node-integration-test:
145+
needs: build
146+
name: Node.js Integration Test
147+
runs-on: ubuntu-latest
148+
steps:
149+
- name: checkout
150+
uses: actions/checkout@v4
151+
- name: setup docker buildx
152+
uses: docker/setup-buildx-action@v3
153+
- name: build docker image
154+
uses: docker/build-push-action@v6
155+
with:
156+
context: .
157+
load: true
158+
tags: bigquery-emulator:test
159+
platforms: linux/amd64
160+
push: false
161+
- name: setup node
162+
uses: actions/setup-node@v4
163+
with:
164+
node-version: '24'
165+
- name: enable corepack
166+
run: corepack enable
167+
- name: cache yarn dependencies
168+
uses: actions/cache@v4
169+
with:
170+
path: test/node/.yarn/cache
171+
key: ${{ runner.os }}-yarn-${{ hashFiles('test/node/yarn.lock') }}
172+
restore-keys: |
173+
${{ runner.os }}-yarn-
174+
- name: install dependencies
175+
run: yarn install --immutable
176+
working-directory: test/node
177+
- name: run integration tests
178+
run: yarn test
179+
working-directory: test/node
180+
env:
181+
BIGQUERY_EMULATOR_REPOSITORY: bigquery-emulator
182+
BIGQUERY_EMULATOR_VERSION: test

test/node/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
*.tsbuildinfo
7+
8+
# Test coverage
9+
coverage/
10+
.nyc_output/
11+
12+
# Environment variables
13+
.env
14+
.env.local
15+
.env.*.local
16+
17+
# IDE
18+
.vscode/
19+
.idea/
20+
*.swp
21+
*.swo
22+
*~
23+
24+
# OS
25+
.DS_Store
26+
Thumbs.db
27+
28+
# Logs
29+
*.log
30+
npm-debug.log*
31+
yarn-debug.log*
32+
yarn-error.log*
33+
34+
# Temporary files
35+
*.tmp
36+
.cache/

test/node/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# BigQuery Emulator - Node.js/TypeScript Tests
2+
3+
This directory contains Node.js/TypeScript tests for the BigQuery emulator using Vitest and Testcontainers.
4+
5+
## Overview
6+
7+
These tests verify that the BigQuery emulator works correctly with the official `@google-cloud/bigquery` Node.js client library.
8+
9+
## Prerequisites
10+
11+
- Node.js 24+
12+
- Yarn package manager
13+
- Docker (for Testcontainers to launch the emulator)
14+
15+
## Installation
16+
17+
Install dependencies using Yarn:
18+
19+
```bash
20+
cd test/node
21+
yarn install
22+
```
23+
24+
## Running Tests
25+
26+
### Run all tests
27+
28+
```bash
29+
yarn test
30+
```
31+
32+
### Run tests in watch mode
33+
34+
```bash
35+
yarn test:watch
36+
```
37+
38+
### Run tests with coverage
39+
40+
```bash
41+
yarn test:coverage
42+
```
43+
44+
### Type checking only
45+
46+
```bash
47+
yarn typecheck
48+
```
49+
50+
## Environment Variables
51+
52+
- `BIGQUERY_EMULATOR_REPOSITORY` - Docker repository for the emulator image (default: `ghcr.io/recidiviz/bigquery-emulator`)
53+
- `BIGQUERY_EMULATOR_VERSION` - Docker image tag (default: `latest`)
54+
- `VITEST_POOL_ID` - Worker ID for parallel test execution (automatically set by Vitest)
55+
56+
57+
## Contributing
58+
59+
When adding new tests:
60+
61+
1. Follow the existing test structure and naming conventions
62+
2. Use the `BigQueryTestHelper` class for common operations
63+
3. Clean up test data in `afterEach` hooks
64+
4. Add comprehensive assertions to verify behavior
65+
5. Include links to Google documentation and filed issues alongside the testcase
66+
67+
## Related Documentation
68+
69+
- [BigQuery Emulator Main README](../../README.md)
70+
- [Python Testing Guide](../python/README.md)
71+
- [Google Cloud BigQuery Node.js Client](https://github.com/googleapis/nodejs-bigquery)
72+
- [Vitest Documentation](https://vitest.dev/)
73+
- [Testcontainers Node.js](https://node.testcontainers.org/)

test/node/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "bigquery-emulator-node-tests",
3+
"version": "1.0.0",
4+
"description": "Node.js/TypeScript tests for BigQuery Emulator",
5+
"type": "module",
6+
"scripts": {
7+
"test": "vitest run",
8+
"test:watch": "vitest",
9+
"test:coverage": "vitest run --coverage",
10+
"typecheck": "tsc --noEmit"
11+
},
12+
"keywords": [
13+
"bigquery",
14+
"emulator",
15+
"testing"
16+
],
17+
"author": "",
18+
"license": "MIT",
19+
"dependencies": {
20+
"@google-cloud/bigquery": "^8.1.1"
21+
},
22+
"devDependencies": {
23+
"@types/node": "^25.2.1",
24+
"@vitest/coverage-v8": "^4.0.18",
25+
"testcontainers": "^11.11.0",
26+
"typescript": "^5.7.3",
27+
"vitest": "^4.0.18"
28+
},
29+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
30+
}

0 commit comments

Comments
 (0)