Skip to content

Commit fcf88d2

Browse files
committed
04/03: improve exercise instructions
1 parent 35921a1 commit fcf88d2

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

Diff for: exercises/04.debugging/01.solution.dom-snapshots/README.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Sometimes the rendered element tree is too large to digest all at once. This is
116116
You can print a single or multiple elements by providing their locators to the `debug()` function:
117117

118118
```tsx nonumber
119-
debug(page.getByRole('button', { name /middle/ }))
119+
debug(page.getByRole('button', { name: /middle/ }).elements())
120120
```
121121

122122
For example, the code above will print all the buttons that have `middle` in their accessible name. Note that the elements you provide to `debug()` don't have to be related in any way. This means you can cherry-pick only those sections of the markup that interest you:

Diff for: exercises/04.debugging/03.problem.breakpoints/src/main-menu.browser.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test('renders the currently active menu link', async () => {
1515
// 🐨 Create another variable called `currentPageLink`.
1616
// For its value, try to find a link element from `allLinks`
1717
// whose "aria-current" attribute equals to "page".
18+
// 💰 allLinks.find(predicate)!
1819
// 💰 element.getAttribute(attributeName)
1920
//
2021
// 🐨 Finally, write an assertion that the `currentPageLink`

Diff for: exercises/04.debugging/03.problem.breakpoints/src/main-menu.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ function MenuItemsList(props: { items: Array<MenuItem> }) {
4242
location.pathname,
4343
)
4444

45+
// 🐨 Right-click on the gutter next to the line with the `return`
46+
// and choose "Add Conditional Breakpoint...".
47+
// 🐨 Enter `item.title === 'Dashboard'` as the breakpoint's condition.
4548
return (
4649
<li key={item.url}>
4750
<NavLink

Diff for: exercises/04.debugging/03.problem.breakpoints/src/tic-tac-toe.browser.test.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ test('places cross marks in a horizontal line', async () => {
66
render(<TicTacToe />)
77

88
await page.getByRole('button', { name: 'left middle' }).click()
9+
// 💣 Remove this debugger statement.
910
debugger
11+
// 🐨 Instead, put a breakpoint on the next line by clicking
12+
// on the gutter next to the line number in your IDE.
1013

1114
await page.getByRole('button', { name: 'middle', exact: true }).click()
15+
// 💣 Repeat the same steps here.
1216
debugger
1317

1418
await page.getByRole('button', { name: 'right middle' }).click()
19+
// 💣 Repeat the same steps here.
1520
debugger
1621

1722
const squares = page.getByRole('button').elements().slice(3, 6)

Diff for: exercises/04.debugging/03.solution.breakpoints/src/main-menu.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function MenuItemsList(props: { items: Array<MenuItem> }) {
5050
'px-2 py-1 hover:text-blue-600 hover:underline',
5151
isActive ? 'font-bold text-black' : 'text-gray-600',
5252
].join(' ')}
53+
end={true}
5354
>
5455
{item.title}
5556
</NavLink>

0 commit comments

Comments
 (0)