-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from gonta1026/feature/set_up
feat: prismaのsetup, e2eテストのsetup,
- Loading branch information
Showing
18 changed files
with
489 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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,7 @@ | ||
# Environment variables declared in this file are automatically made available to Prisma. | ||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema | ||
|
||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. | ||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings | ||
|
||
DATABASE_URL="postgresql://root:password@localhost:5434/next-template?schema=public" |
This file contains 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 |
---|---|---|
|
@@ -34,3 +34,6 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
## 以下追加分 | ||
test-results |
This file contains 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 |
---|---|---|
|
@@ -12,4 +12,6 @@ npm install -g git-cz | |
|
||
``` | ||
git cz | ||
``` | ||
``` | ||
|
||
### db set up |
This file contains 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,15 @@ | ||
version: "3.8" | ||
services: | ||
dev-postgres: | ||
image: postgres:16.3-alpine | ||
ports: | ||
- 5434:5432 | ||
environment: | ||
POSTGRES_USER: root | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: next-template | ||
restart: always | ||
networks: | ||
- lesson | ||
networks: | ||
lesson: |
This file contains 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,33 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test' | ||
// biome-ignore lint/style/useNodejsImportProtocol: <explanation> | ||
import path from 'path' | ||
|
||
const PORT = process.env.PORT || 3000 | ||
const baseURL = `http://localhost:${PORT}` | ||
|
||
const config: PlaywrightTestConfig = { | ||
timeout: 5 * 1000, | ||
testDir: path.join(__dirname, 'src/e2e'), | ||
retries: 0, | ||
webServer: { | ||
command: 'npm start', | ||
url: baseURL, | ||
timeout: 120 * 1000, | ||
reuseExistingServer: true, | ||
}, | ||
// globalSetup: './e2e/config/globalSetup.ts', | ||
use: { | ||
baseURL, | ||
// storageState: './e2e/config/storageState.json', | ||
}, | ||
// reporter: [['html', { open: 'always' }]], | ||
// projects: [ | ||
// { | ||
// name: 'Desktop Chrome', | ||
// use: { | ||
// ...devices['Desktop Chrome'], | ||
// }, | ||
// }, | ||
// ], | ||
} | ||
export default config |
This file contains 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,12 @@ | ||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" SERIAL NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"hashedPassword" TEXT NOT NULL, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); |
This file contains 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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains 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,5 @@ | ||
import type { PrismaClient } from '@prisma/client' | ||
|
||
export const reset = async (prisma: PrismaClient) => { | ||
await prisma.user.deleteMany({}) | ||
} |
This file contains 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,16 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? | ||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["prismaSchemaFolder"] | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
This file contains 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,6 @@ | ||
model User { | ||
id Int @id @default(autoincrement()) | ||
email String @unique | ||
name String | ||
hashedPassword String | ||
} |
This file contains 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,26 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
import { reset } from './reset' | ||
|
||
const prisma = new PrismaClient() | ||
|
||
async function main() { | ||
await reset(prisma) | ||
await prisma.user.create({ | ||
data: { | ||
id: 1, | ||
name: '東京駅内の店', | ||
email: 'test@example.com', | ||
hashedPassword: 'ssss', | ||
}, | ||
}) | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect() | ||
}) | ||
.catch(async (e) => { | ||
console.error(e) | ||
await prisma.$disconnect() | ||
process.exit(1) | ||
}) |
This file contains 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 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,7 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('Shall render hello world', async ({ page }) => { | ||
await page.goto('/') | ||
await expect(page).toHaveTitle('e2e lesson') | ||
await expect(page.locator('h1')).toHaveText('Hello World🚀') | ||
}) |
This file contains 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
Oops, something went wrong.