-
Notifications
You must be signed in to change notification settings - Fork 0
Project Setup
F.S. Koulen edited this page May 17, 2023
·
12 revisions
Environment Variables
# Set to false if you want to enable the PWA while developing locally
# NOTE: this should not be disabled in other environments
NEXT_PUBLIC_DISABLE_PWA=true
# URL of your Supabase instance (start up supabase locally if you're making changes to the database)
NEXT_PUBLIC_SUPABASE_URL=
# Anon key of your Supabase instance (can be retrieved from either your terminal where you've started your Supabase
# instance or through the settings on Supabase)
NEXT_PUBLIC_SUPABASE_ANON_KEY=
# Tells Cypress where the website is hosted
CYPRESS_BASE_URL=http://127.0.0.1:3000
# How long Cypress should wait for action before failing a test
CYPRESS_TIMEOUT_SECONDS=12
# The number of test retires when running `cypress run`
CYPRESS_RETRY_MODE_RUN=2
NPM Packages
- firebase
- next-pwa
- @heroicons/react
- sharp (for next.js image optimization)
- react-hook-form
- date-fns to format Date object
- superjson to allow Date objects to be passed to getStaticProps
Supabase
- supabase
- @supabase/supabase-js
- @supabase/auth-helpers-nextjs
- @supabase/auth-helpers-react
Jest
- jest
- ts-jest
Prettier
- eslint-config-prettier
- husky (for pre-commit hook)
- lint-staged (to run linters against staged files)
- prettier
- prettier-plugin-tailwindcss
Cypress
- cypress
- cypress-firebase
- esbuild (fixes the following bug: https://github.com/prescottprue/cypress-firebase/issues/788)
- dotenv (Required for retrieving environment variables in Cypress config)
Redux
- @reduxjs/toolkit
- next-redux-wrapper
- react-redux
Initial packages
- @types/node
- @types/react
- @types/react-dom
- autoprefixer
- eslint
- eslint-config-next
- next
- postcss
- react
- react-dom
- typescript
https://github.com/ASVGay/the-rhapsodies/pull/56
This PR will set up Cypress with cypress-firebase for E2E or
component testing.
- Use cy:open to run the tests in the GUI and cy:run to run the tests in your CLI.
- Before starting Cypress make sure to have done the following:
- Go to Authentication page of the Firebase Console and select an existing user to use as the testing account or create a new user. This will be the account which you use to login while running tests.
- Get the UID of the account you have selected and add it to your .env file with the name TEST_UID
- Insert the email and password of this account to your cypress.env.json file with the names user_email, and user_password.
- Insert the email and password of an account with the additional user property of isFirstLogin to true to the cypress.env.json file with the names user_first_time_email and user_first_time_password.
- Generate and download a service account as described in the firebase-admin setup documentation. Save this to a local file called serviceAccount.json. Make sure YOU DO NOT COMMIT THIS FILE (it is already in the .gitignore). Then set an environment variable name GOOGLE_APPLICATION_CREDENTIALS with the value being the complete path to the serviceAccount.json
You can now use the following commands in your tests: https://github.com/prescottprue/cypress-firebase/#docs
Packages that will be installed: cypress, cypress-firebase, dotenv.
-
Set up Supabase CLI
Note: You must have docker installed and running. - Auth helpers for Next.js
- Run
supabase gen types typescript --local > src/types/database.types.ts
- Change the file encoding from
UTF-16LE
toUTF-8
(because of https://github.com/supabase/supabase/issues/9215)
For row level security to work properly when fetching data client-side, you need to make sure to use the supabaseClient from the useSupabaseClient hook and only run your query once the user is defined client-side in the useUser() hook. [source]