Skip to content

Commit

Permalink
feat: Add integration testing (#105)
Browse files Browse the repository at this point in the history
* feat: Integration tests

* feat: Test indexes for all packages

* feat: Integration tests!

* fix: lockfile

* fix: Prettier

* fix: CI

* fix: CI

* fix: Naming

* feat: Env vars in actions

* fix: Remove condition from dev integration tests

* fix: Unit tests that shouldn't throw

* fix: Dev command for integration tests

* fix: Test data

* fix: New db

* fix: Dumb date tz stuff

* fix: Node version in integration tests, better errors

* fix: ugh

* feat: README

* feat: Move tooling packages to tooling dir

* feat: Apply config changes fo rnew package locations

* feat: Move tests to their own dir

* fix: Update README

* fix: README
  • Loading branch information
1 parent c4a8aa5 commit a514ec1
Show file tree
Hide file tree
Showing 68 changed files with 5,313 additions and 79 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module.exports = {
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ['custom'],
parserOptions: {
project: resolve(__dirname, './packages/*/tsconfig.json'),
project: [
resolve(__dirname, './packages/*/tsconfig.json'),
resolve(__dirname, './tooling/*/tsconfig.json'),
],
},
};
36 changes: 36 additions & 0 deletions .github/workflows/integration-tests-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Playwright Dev Tests

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Install dependencies
run: pnpm install

- name: Install Playwright
run: npx playwright install --with-deps

- name: Run Playwright tests in development mode
run: pnpm integration-test
39 changes: 39 additions & 0 deletions .github/workflows/integration-tests-live.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Playwright Live Tests

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}

on:
deployment_status:

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success'
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Install dependencies
run: pnpm install

- name: Install Playwright
run: npx playwright install --with-deps

- name: Run Playwright tests on ${{ github.event.deployment_status.target_url }}
run: npx playwright test
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }}

- name: Run Playwright tests in development mode
run: pnpm integration-test
3 changes: 2 additions & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Quality
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}
on:
push:
branches: [main]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Release
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}

on:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: CI
name: Unit Tests

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}

on:
push:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ npm-debug.log

.turbo
.DS_Store
.vscode
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
dist
node_modules
pnpm-lock.yaml
pnpm-lock.yaml
.next
.vercel
.vscode
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"license": "Apache-2.0",
"scripts": {
"build": "turbo build",
"integration-test": "turbo integration-test",
"lint": "turbo lint -- --max-warnings=0",
"prepare": "husky install",
"prettier-check": "prettier --check .",
"prettier-fix": "prettier --write .",
"publint": "turbo publint",
"release": "pnpm build && changeset publish",
"run-integration": "pnpm -F vercel-storage-integration-test-suite dev",
"test": "turbo test",
"type-check": "turbo type-check",
"version-packages": "changeset version && pnpm i --no-frozen-lockfile && git add ."
Expand Down
4 changes: 1 addition & 3 deletions packages/postgres/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { VercelPostgresError } from './error';
import {
createClient,
createPool,
Expand All @@ -16,12 +15,11 @@ describe('@vercel/postgres', () => {
});
it('exports sql', () => {
expect(typeof sql).toEqual('function');
expect(() => sql.connect()).toThrow(VercelPostgresError);
});
it('exports postgresConnectionString', () => {
expect(typeof postgresConnectionString).toEqual('function');
});
it('exports a default db pool instance', () => {
expect(() => db.connect()).toThrow(VercelPostgresError);
expect(typeof db).toEqual('function');
});
});
Loading

0 comments on commit a514ec1

Please sign in to comment.