Skip to content

Commit

Permalink
Merge pull request #30 from cw-yashiro/add-e2e
Browse files Browse the repository at this point in the history
Add e2e
  • Loading branch information
cw-yashiro authored Jul 28, 2024
2 parents 74a53d2 + 076e0cd commit 0cbb64d
Show file tree
Hide file tree
Showing 7 changed files with 6,884 additions and 894 deletions.
5 changes: 5 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ actual

# Test Coverage
coverage

.reg
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
Binary file removed frontend/.yarn/install-state.gz
Binary file not shown.
894 changes: 0 additions & 894 deletions frontend/.yarn/releases/yarn-4.3.0.cjs

This file was deleted.

19 changes: 19 additions & 0 deletions frontend/e2e/can-register-todo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { test, expect } from "@playwright/test"

// TODO: テストごとに条件を同じにするために、DBのリセット処理をできるようにする

test("タスクを登録できる", async ({ page }) => {
// ページに遷移する
await page.goto("http://localhost:5173")

// フォームにタスクを入力する
const form = page.locator("textarea")
await form.fill("テストタスク")

// 追加ボタンを押す
const button = page.locator("button")
await button.click()

// タスク一覧に表示されている
await expect(page.locator("li")).toContainText("テストタスク")
})
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"@chromatic-com/storybook": "^1.3.5",
"@playwright/test": "^1.45.3",
"@storybook/addon-essentials": "^8.0.10",
"@storybook/addon-interactions": "^8.0.10",
"@storybook/addon-links": "^8.0.10",
Expand All @@ -32,6 +33,7 @@
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^22.0.0",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.2.0",
Expand Down
78 changes: 78 additions & 0 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
Loading

0 comments on commit 0cbb64d

Please sign in to comment.