Challenge - 5 Problems
Playwright Remix Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the test result of this Playwright snippet?
Consider this Playwright test code for a Remix app login page. What will be the test execution result?
Remix
import { test, expect } from '@playwright/test'; test('login button is visible', async ({ page }) => { await page.goto('/login'); const loginButton = page.locator('button[type="submit"]'); await expect(loginButton).toBeVisible(); });
Attempts:
2 left
💡 Hint
Check the locator syntax and the use of await for asynchronous calls.
✗ Incorrect
The locator 'button[type="submit"]' correctly selects the submit button. The test waits for the page to load and asserts visibility. The await keyword is correctly used before page.goto and expect.
❓ locator
intermediate2:00remaining
Choose the best locator for a navigation link in Remix
You want to select a navigation link with the text 'Dashboard' in a Remix app for your Playwright test. Which locator is best practice?
Attempts:
2 left
💡 Hint
Consider stability and specificity of locators in tests.
✗ Incorrect
Using the href attribute is more stable and specific than text-based locators, which can change. Option B targets the exact link by URL.
❓ assertion
advanced2:00remaining
Which assertion correctly verifies an error message appears?
You want to check that an error message with text 'Invalid credentials' appears after a failed login in your Remix app test. Which assertion is correct?
Remix
const errorMessage = page.locator('.error-message');Attempts:
2 left
💡 Hint
Check the Playwright assertion methods for text content.
✗ Incorrect
toContainText checks if the element's text includes the given string, which is suitable for error messages. toHaveText requires exact match. toBeVisible does not accept text argument. toHaveValue is for input elements.
🔧 Debug
advanced2:00remaining
Why does this Playwright test fail intermittently?
This test sometimes fails with a timeout error. What is the likely cause?
Code:
await page.goto('/profile');
await page.click('button#load-data');
await expect(page.locator('.data-loaded')).toBeVisible();
Attempts:
2 left
💡 Hint
Think about asynchronous actions after clicking a button.
✗ Incorrect
Clicking the button triggers data loading asynchronously. The test must wait for the data to appear. Without explicit wait, the assertion may run too early causing timeout.
❓ framework
expert2:00remaining
How to integrate Playwright tests in a Remix app CI pipeline?
Which approach correctly integrates Playwright end-to-end tests into a Remix app continuous integration (CI) pipeline?
Attempts:
2 left
💡 Hint
Consider the app state required for end-to-end tests.
✗ Incorrect
Playwright tests require the built app to be available. Running tests after building ensures the app is ready. Running tests before build or without build will fail.