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">
<a className="nav-btn">Pricing</a>
<a id="pricing" className="nav-btn">
Pricing
</a>
</Link>
<Link href="/contact">
<a className="nav-btn">Contact Us</a>
<a id="contact" className="nav-btn">
Contact Us
</a>
</Link>
{user ? (
@@ -39,10 +43,14 @@ const Nav = ({ user, signOut }: NavProps): JSX.Element => {
) : (
<>
<Link href="/login">
<a className="nav-btn">Login</a>
<a id="login" className="nav-btn">
Login
</a>
</Link>
<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>
</>
)}

View File

@@ -1,8 +1,13 @@
import { expect, test } from '@playwright/test';
test('basic test', async ({ page }) => {
console.log(process.env.PLAYWRIGHT_TEST_BASE_URL);
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner .navbar__title');
await expect(title).toHaveText('Playwright');
const myURL: string = process.env.PLAYWRIGHT_TEST_BASE_URL
? process.env.PLAYWRIGHT_TEST_BASE_URL
: ('http://localhost:3000/' as string);
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 },
},
},
// 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;