Added first basic test with playwright

This commit is contained in:
Michael
2021-10-22 17:55:37 +02:00
parent ef01ece55f
commit 397fce4b73
3 changed files with 21 additions and 19 deletions

View File

@@ -24,11 +24,15 @@ const Nav = ({ user, signOut }: NavProps): JSX.Element => {
)} )}
<Link href="/pricing"> <Link href="/pricing">
<a className="nav-btn">Pricing</a> <a id="pricing" className="nav-btn">
Pricing
</a>
</Link> </Link>
<Link href="/contact"> <Link href="/contact">
<a className="nav-btn">Contact Us</a> <a id="contact" className="nav-btn">
Contact Us
</a>
</Link> </Link>
{user ? ( {user ? (
@@ -39,10 +43,14 @@ const Nav = ({ user, signOut }: NavProps): JSX.Element => {
) : ( ) : (
<> <>
<Link href="/login"> <Link href="/login">
<a className="nav-btn">Login</a> <a id="login" className="nav-btn">
Login
</a>
</Link> </Link>
<Link href="/signup"> <Link href="/signup">
<a className="btn btn-sm btn-primary font-body normal-case font-normal">Sign Up</a> <a id="signup" className="btn btn-sm btn-primary font-body normal-case font-normal">
Sign Up
</a>
</Link> </Link>
</> </>
)} )}

View File

@@ -1,8 +1,13 @@
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
test('basic test', async ({ page }) => { test('basic test', async ({ page }) => {
console.log(process.env.PLAYWRIGHT_TEST_BASE_URL); const myURL: string = process.env.PLAYWRIGHT_TEST_BASE_URL
await page.goto('https://playwright.dev/'); ? process.env.PLAYWRIGHT_TEST_BASE_URL
const title = page.locator('.navbar__inner .navbar__title'); : ('http://localhost:3000/' as string);
await expect(title).toHaveText('Playwright');
await page.goto(myURL);
// Go through all pages
await page.click('#login');
await page.click('#pricing');
await page.click('#signup');
}); });

View File

@@ -25,17 +25,6 @@ const config: PlaywrightTestConfig = {
viewport: { width: 1200, height: 750 }, viewport: { width: 1200, height: 750 },
}, },
}, },
// Test against mobile viewports.
{
name: 'Desktop Firefox',
use: {
baseURL: process.env.NEXT_PUBLIC_VERCEL_URL
? process.env.NEXT_PUBLIC_VERCEL_URL
: 'http://localhost:3000',
browserName: 'firefox',
viewport: { width: 800, height: 600 },
},
},
], ],
}; };
export default config; export default config;