Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: convert backend test to Playwright #54641

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/temporary-container-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ jobs:
config: baseUrl=http://localhost:8000
browser: ${{ matrix.browsers }}
# Only run one test to keep the run time down.
spec: 'cypress/e2e/default/learn/challenges/backend.ts'
spec: 'cypress/e2e/default/learn/challenges/codeally.ts'
36 changes: 0 additions & 36 deletions cypress/e2e/default/learn/challenges/backend.ts

This file was deleted.

30 changes: 30 additions & 0 deletions e2e/backend.spec.ts
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();
});
});