Skip to content
Closed
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
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ NEXTAUTH_URL=http://localhost:3000

### Running tests

You can run tests locally with _npm run test:e2e_
Run _npm init playwright@latest_ then copy over _drizzle.config.ts_ to your repository.

Now you can run tests locally with _npm run test:e2e_

### Assumptions that tests make

Expand All @@ -63,23 +65,23 @@ Tests are making several assumptions on your UI:
Eg. the below tests assumes that the url of the creation form is _/blogs/new_, form controls have the labels and eg. the creation button has test id _create-blog-button_:

```js
test("logged in user can create a blog", async ({ page }) => {
await loginUser(page, "testuser", "testpass123")
test('logged in user can create a blog', async ({ page }) => {
await loginUser(page, 'testuser', 'testpass123')

await page.goto("/blogs/new")
await page.getByLabel("Title", { exact: true }).fill("Test Blog")
await page.getByLabel("Author", { exact: true }).fill("Test Author")
await page.getByLabel("URL", { exact: true }).fill("http://testblog.com")
await page.getByTestId("create-blog-button").click()
await page.goto('/blogs/new')
await page.getByLabel('Title', { exact: true }).fill('Test Blog')
await page.getByLabel('Author', { exact: true }).fill('Test Author')
await page.getByLabel('URL', { exact: true }).fill('http://testblog.com')
await page.getByTestId('create-blog-button').click()

// Should redirect to blogs page
await expect(page).toHaveURL("/blogs")
await expect(page).toHaveURL('/blogs')

// Should show success notification
await expect(page.getByTestId("notification")).toBeVisible()
await expect(page.getByTestId('notification')).toBeVisible()

// Blog should appear in the list
await expect(page.getByTestId("blogs-list")).toContainText("Test Blog")
await expect(page.getByTestId('blogs-list')).toContainText('Test Blog')
})
```

Expand Down
18 changes: 18 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default defineConfig({
testDir: './tests',
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: 1,
reporter: 'html',
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
})