-
Notifications
You must be signed in to change notification settings - Fork 533
test: add integration tests for next js #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6ff1739
test: add integration tests for next js
grdsdev 29c42c6
use npm
grdsdev c853ea3
install playwright
grdsdev a1d2ec2
test: fixing the pipeline (#1464)
georgRusanov 8398b24
remove playwright test results from git
grdsdev b05d2f7
remove packageManager from package.json file
grdsdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,80 +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 | ||||||
|
||||||
| npm run test:integration || npm run test:integration | |
| npm run test:integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Update these with your Supabase details from your project settings > API | ||
| # https://app.supabase.com/project/_/settings/api | ||
| NEXT_PUBLIC_SUPABASE_URL=your-project-url | ||
| NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/versions | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # env files (can opt-in for committing if needed) | ||
| .env*.local | ||
| .env | ||
|
|
||
| # vercel | ||
| .vercel | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts | ||
|
|
||
| # playwright | ||
| playwright-report | ||
| test-results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| <a href="https://demo-nextjs-with-supabase.vercel.app/"> | ||
| <img alt="Next.js and Supabase Starter Kit - the fastest way to build apps with Next.js and Supabase" src="https://demo-nextjs-with-supabase.vercel.app/opengraph-image.png"> | ||
| <h1 align="center">Next.js and Supabase Starter Kit</h1> | ||
| </a> | ||
|
|
||
| <p align="center"> | ||
| The fastest way to build apps with Next.js and Supabase | ||
| </p> | ||
|
|
||
| <p align="center"> | ||
| <a href="#features"><strong>Features</strong></a> · | ||
| <a href="#demo"><strong>Demo</strong></a> · | ||
| <a href="#deploy-to-vercel"><strong>Deploy to Vercel</strong></a> · | ||
| <a href="#clone-and-run-locally"><strong>Clone and run locally</strong></a> · | ||
| <a href="#feedback-and-issues"><strong>Feedback and issues</strong></a> | ||
| <a href="#more-supabase-examples"><strong>More Examples</strong></a> | ||
| </p> | ||
| <br/> | ||
|
|
||
| ## Features | ||
|
|
||
| - Works across the entire [Next.js](https://nextjs.org) stack | ||
| - App Router | ||
| - Pages Router | ||
| - Middleware | ||
| - Client | ||
| - Server | ||
| - It just works! | ||
| - supabase-ssr. A package to configure Supabase Auth to use cookies | ||
| - Password-based authentication block installed via the [Supabase UI Library](https://supabase.com/ui/docs/nextjs/password-based-auth) | ||
| - Styling with [Tailwind CSS](https://tailwindcss.com) | ||
| - Components with [shadcn/ui](https://ui.shadcn.com/) | ||
| - Optional deployment with [Supabase Vercel Integration and Vercel deploy](#deploy-your-own) | ||
| - Environment variables automatically assigned to Vercel project | ||
|
|
||
| ## Demo | ||
|
|
||
| You can view a fully working demo at [demo-nextjs-with-supabase.vercel.app](https://demo-nextjs-with-supabase.vercel.app/). | ||
|
|
||
| ## Deploy to Vercel | ||
|
|
||
| Vercel deployment will guide you through creating a Supabase account and project. | ||
|
|
||
| After installation of the Supabase integration, all relevant environment variables will be assigned to the project so the deployment is fully functioning. | ||
|
|
||
| [](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&project-name=nextjs-with-supabase&repository-name=nextjs-with-supabase&demo-title=nextjs-with-supabase&demo-description=This+starter+configures+Supabase+Auth+to+use+cookies%2C+making+the+user%27s+session+available+throughout+the+entire+Next.js+app+-+Client+Components%2C+Server+Components%2C+Route+Handlers%2C+Server+Actions+and+Middleware.&demo-url=https%3A%2F%2Fdemo-nextjs-with-supabase.vercel.app%2F&external-id=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&demo-image=https%3A%2F%2Fdemo-nextjs-with-supabase.vercel.app%2Fopengraph-image.png) | ||
|
|
||
| The above will also clone the Starter kit to your GitHub, you can clone that locally and develop locally. | ||
|
|
||
| If you wish to just develop locally and not deploy to Vercel, [follow the steps below](#clone-and-run-locally). | ||
|
|
||
| ## Clone and run locally | ||
|
|
||
| 1. You'll first need a Supabase project which can be made [via the Supabase dashboard](https://database.new) | ||
|
|
||
| 2. Create a Next.js app using the Supabase Starter template npx command | ||
|
|
||
| ```bash | ||
| npx create-next-app --example with-supabase with-supabase-app | ||
| ``` | ||
|
|
||
| ```bash | ||
| yarn create next-app --example with-supabase with-supabase-app | ||
| ``` | ||
|
|
||
| ```bash | ||
| pnpm create next-app --example with-supabase with-supabase-app | ||
| ``` | ||
|
|
||
| 3. Use `cd` to change into the app's directory | ||
|
|
||
| ```bash | ||
| cd with-supabase-app | ||
| ``` | ||
|
|
||
| 4. Rename `.env.example` to `.env.local` and update the following: | ||
|
|
||
| ``` | ||
| NEXT_PUBLIC_SUPABASE_URL=[INSERT SUPABASE PROJECT URL] | ||
| NEXT_PUBLIC_SUPABASE_ANON_KEY=[INSERT SUPABASE PROJECT API ANON KEY] | ||
| ``` | ||
|
|
||
| Both `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` can be found in [your Supabase project's API settings](https://supabase.com/dashboard/project/_?showConnect=true) | ||
|
|
||
| 5. You can now run the Next.js local development server: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| The starter kit should now be running on [localhost:3000](http://localhost:3000/). | ||
|
|
||
| 6. This template comes with the default shadcn/ui style initialized. If you instead want other ui.shadcn styles, delete `components.json` and [re-install shadcn/ui](https://ui.shadcn.com/docs/installation/next) | ||
|
|
||
| > Check out [the docs for Local Development](https://supabase.com/docs/guides/getting-started/local-development) to also run Supabase locally. | ||
|
|
||
| ## Feedback and issues | ||
|
|
||
| Please file feedback and issues over on the [Supabase GitHub org](https://github.com/supabase/supabase/issues/new/choose). | ||
|
|
||
| ## More Supabase examples | ||
|
|
||
| - [Next.js Subscription Payments Starter](https://github.com/vercel/nextjs-subscription-payments) | ||
| - [Cookie-based Auth and the Next.js 13 App Router (free course)](https://youtube.com/playlist?list=PL5S4mPUpp4OtMhpnp93EFSo42iQ40XjbF) | ||
| - [Supabase Auth and the Next.js App Router](https://github.com/supabase/supabase/tree/master/examples/auth/nextjs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| 'use client' | ||
|
|
||
| import { useEffect, useState } from 'react' | ||
| import { createClient } from '@/lib/supabase/client' | ||
|
|
||
| export default function Home() { | ||
| const supabase = createClient() | ||
| const [realtimeStatus, setRealtimeStatus] = useState<string | null>(null) | ||
| const channel = supabase.channel('realtime:public:test') | ||
|
|
||
| useEffect(() => { | ||
| channel.subscribe((status) => setRealtimeStatus(status)) | ||
|
|
||
| return () => { | ||
| channel.unsubscribe() | ||
| } | ||
| }, []) | ||
|
|
||
| return <div data-testid="realtime_status">{realtimeStatus}</div> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "$schema": "https://ui.shadcn.com/schema.json", | ||
| "style": "new-york", | ||
| "rsc": true, | ||
| "tsx": true, | ||
| "tailwind": { | ||
| "config": "", | ||
| "css": "app/globals.css", | ||
| "baseColor": "neutral", | ||
| "cssVariables": true, | ||
| "prefix": "" | ||
| }, | ||
| "aliases": { | ||
| "components": "@/components", | ||
| "utils": "@/lib/utils", | ||
| "ui": "@/components/ui", | ||
| "lib": "@/lib", | ||
| "hooks": "@/hooks" | ||
| }, | ||
| "iconLibrary": "lucide" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { dirname } from 'path' | ||
| import { fileURLToPath } from 'url' | ||
| import { FlatCompat } from '@eslint/eslintrc' | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url) | ||
| const __dirname = dirname(__filename) | ||
|
|
||
| const compat = new FlatCompat({ | ||
| baseDirectory: __dirname, | ||
| }) | ||
|
|
||
| const eslintConfig = [...compat.extends('next/core-web-vitals', 'next/typescript')] | ||
|
|
||
| export default eslintConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { createBrowserClient } from '@supabase/ssr' | ||
|
|
||
| export function createClient() { | ||
| return createBrowserClient( | ||
| process.env.NEXT_PUBLIC_SUPABASE_URL || 'http://127.0.0.1:54321', | ||
| process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || | ||
| 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duplicate execution using the '||' operator is unnecessary here as well; removing the duplicate command can simplify the CI script.