forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: convert backend test to Playwright (freeCodeCamp#54641)
- Loading branch information
Showing
3 changed files
with
31 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const locations = { | ||
index: | ||
'learn/back-end-development-and-apis/managing-packages-with-npm/' + | ||
'how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package' | ||
}; | ||
|
||
const unhandledErrorMessage = 'Something is not quite right'; | ||
const runningOutput = '// running tests'; | ||
const finishedOutput = '// tests completed'; | ||
|
||
test.describe('Backend challenge', () => { | ||
test('renders', async ({ page }) => { | ||
await page.goto(locations.index); | ||
await expect(page).toHaveTitle( | ||
'Managing Packages with NPM - How to Use package.json, the Core of Any Node.js Project or npm Package | Learn | freeCodeCamp.org' | ||
); | ||
}); | ||
|
||
test('does not generate unhandled errors on submission', async ({ page }) => { | ||
await page.goto(locations.index); | ||
await page.fill('input[name="solution"]', 'https://example.com'); | ||
await page.keyboard.press('Enter'); | ||
|
||
await expect(page.getByText(runningOutput)).toContainText(finishedOutput); | ||
|
||
await expect(page.getByText(unhandledErrorMessage)).not.toBeVisible(); | ||
}); | ||
}); |