await page.getStarted(); // what does this actually do?
vs await page.locator('a', { hasText: 'Get started' }).first().click();
await expect(page.locator('h1', { hasText: 'Installation' })).toBeVisible();
The second version is explicit and self-documenting. Tests don't always benefit from aggressive DRY, but I've seen teams adopt POMs to coordinate between SDETs and SWEs. type Node<T> = { value: T, left?: Node<T>, right?: Node<T> }
Given a root, you can invert it recursively with some code like this: function invertTree(root) {
if (!root) return null;
// Swap!
const tmp = root.left;
root.left = invertTree(root.right);
root.right = invertTree(tmp);
return root;
};
Or using an explicit stack: function invertTree(root) {
const stack = [root];
while (stack.length > 0) {
const node = stack.pop(); if (!node) continue;
// Swap!
const tmp = node.right;
node.right = node.left;
node.left = tmp;
stack.push(node.left);
stack.push(node.right);
}
return root;
}
I think without prep would be harder to come up with the non-recursive version.
0: https://www.zojirushi.com/blog/design-explained-our-easy-rel...
1: https://www.mcmaster.com/products/breakaway-magnetic-connect...