forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.spec.ts
30 lines (24 loc) · 1.06 KB
/
backend.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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();
});
});