Skip to content

Commit

Permalink
feat: convert backend test to Playwright (#54641)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sembauke committed May 7, 2024
1 parent c3b5c11 commit 50d7f03
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 37 deletions.
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();
});
});

0 comments on commit 50d7f03

Please sign in to comment.