Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 67 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,87 +20,114 @@ on:

jobs:
test:
name: Test / OS ${{ matrix.os }} / Node ${{ matrix.node }}
name: Unit + Type Check / Node.js ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node: ['20']

runs-on: ${{ matrix.os }}

node: [20]
steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Run tests
run: |
npm clean-install
npm run test:coverage
- run: npm clean-install

- name: Type Check
run: npm run test:types

- name: Run Unit Tests + Coverage
run: npm run test:coverage

- name: Upload coverage results to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./test/coverage/lcov.info

integration:
name: Integration / OS ${{ matrix.os }} / Node ${{ matrix.node }} / Deno ${{ matrix.deno }}
deno-tests:
name: Deno Tests / ${{ matrix.deno }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node: ['20']
deno: ['1.x', '2.x']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- uses: denoland/setup-deno@v2
with:
deno-version: ${{ matrix.deno }}

- name: Setup Supabase
uses: supabase/setup-cli@v1
- uses: supabase/setup-cli@v1
with:
version: latest

- name: Start Supabase
run: |
supabase start
run: supabase start

- name: Build
- name: Run Deno Tests
run: |
npm clean-install
npm run build
cd test/deno
npm install
npm test || npm test

- name: Run tests
- name: Run integration and browser tests on Deno 2.x only
if: ${{ matrix.deno == '2.x' }}
run: |
npm run test:integration || npm run test:integration
npm run test:integration:browser

- name: Run Deno tests
- name: Stop Supabase
run: supabase stop

node-integration:
name: Node Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: supabase/setup-cli@v1
with:
version: latest

- name: Start Supabase
run: supabase start

- name: Run integration tests
run: |
cd test/deno
npm test || npm test
npm clean-install
npm run build
npm run test:integration || npm run test:integration

- name: Next.js Integration Tests
- name: Stop Supabase
run: supabase stop

next-integration:
name: Next.js Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: supabase/setup-cli@v1
with:
version: latest

- name: Start Supabase
run: supabase start

- name: Install Playwright browsers and dependencies
run: npx playwright install --with-deps

- name: Run integration tests
run: |
cd test/integration/next
npm install
npx playwright install
npm run test
npm run test

- name: Stop Supabase
run: |
supabase stop
run: supabase stop
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
"test": "run-s test:types test:run",
"test:all": "run-s test:types test:run test:integration test:integration:browser",
"test:run": "jest --runInBand --detectOpenHandles",
"test:unit": "jest --runInBand --detectOpenHandles test/unit",
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration.*|test/deno.*\"",
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
"test:db": "cd infra/db && docker-compose down && docker-compose up -d && sleep 5",
"test:watch": "jest --watch --verbose false --silent false",
"test:clean": "cd infra/db && docker-compose down",
"test:types": "run-s build:module && tsd --files test/*.test-d.ts",
"test:types": "run-s build:module && tsd --files test/types/*.test-d.ts",
"docs": "typedoc --entryPoints src/index.ts --out docs/v2 --includes src/**/*.ts",
"docs:json": "typedoc --entryPoints src/index.ts --includes src/**/*.ts --json docs/v2/spec.json --excludeExternals",
"serve:coverage": "npm run test:coverage && serve test/coverage"
Expand Down
4 changes: 2 additions & 2 deletions test/index.test-d.ts → test/types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectError, expectType } from 'tsd'
import { PostgrestSingleResponse, createClient } from '../src/index'
import { Database, Json } from './types'
import { PostgrestSingleResponse, createClient } from '../../src/index'
import { Database, Json } from '../types'

const URL = 'http://localhost:3000'
const KEY = 'some.fake.key'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SupabaseAuthClient } from '../src/lib/SupabaseAuthClient'
import SupabaseClient from '../src/SupabaseClient'
import { DEFAULT_HEADERS } from '../src/lib/constants'
import { SupabaseAuthClient } from '../../src/lib/SupabaseAuthClient'
import SupabaseClient from '../../src/SupabaseClient'
import { DEFAULT_HEADERS } from '../../src/lib/constants'

const DEFAULT_OPTIONS = {
auth: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PostgrestClient } from '@supabase/postgrest-js'
import { createClient, SupabaseClient } from '../src/index'
import { Database } from './types'
import { createClient, SupabaseClient } from '../../src/index'
import { Database } from '../types'

const URL = 'http://localhost:3000'
const KEY = 'some.fake.key'
Expand Down
4 changes: 2 additions & 2 deletions test/constants.test.ts → test/unit/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DEFAULT_HEADERS } from '../src/lib/constants'
import { version } from '../src/lib/version'
import { DEFAULT_HEADERS } from '../../src/lib/constants'
import { version } from '../../src/lib/version'

test('it has the correct type of returning with the correct value', () => {
let JS_ENV = ''
Expand Down
2 changes: 1 addition & 1 deletion test/helper.test.ts → test/unit/helper.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ensureTrailingSlash } from '../src/lib/helpers'
import { ensureTrailingSlash } from '../../src/lib/helpers'

test('Adds trailing slash to URL if missing', () => {
const input = 'http://localhost:3000'
Expand Down
4 changes: 2 additions & 2 deletions test/helpers.test.ts → test/unit/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as helpers from '../src/lib/helpers'
import { DEFAULT_HEADERS } from '../src/lib/constants'
import * as helpers from '../../src/lib/helpers'
import { DEFAULT_HEADERS } from '../../src/lib/constants'

test('uuid', async () => {
expect(helpers.uuid()).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)
Expand Down