Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Sep 17, 2024
1 parent 25893e3 commit 9820860
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 20 deletions.
9 changes: 8 additions & 1 deletion exercises/04.router/01.problem.router/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/04.router/01.solution.router/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/04.router/04.problem.history/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/04.router/04.solution.history/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/04.router/05.problem.cache/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/04.router/05.solution.cache/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/05.actions/02.problem.client/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/05.actions/02.solution.client/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/05.actions/03.problem.server/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
9 changes: 8 additions & 1 deletion exercises/05.actions/03.solution.server/tests/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ test('should display the home page and perform search', async ({ page }) => {

// Perform a search
await filterInput.fill('hopper')
await filterInput.press('Enter')

// Verify URL change with search params
await expect(page).toHaveURL('/?search=hopper')

const shipList = page.getByRole('list').first()

// Wait for the list to be filtered down to two items
await expect(async () => {
const items = await shipList.getByRole('listitem').all()
expect(items.length).toBe(2)
}).toPass()

// Verify filtered results
const shipLinks = page
.getByRole('list')
Expand Down

0 comments on commit 9820860

Please sign in to comment.