forked from react-navigation/react-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: configure playwright for e2e tests
- Loading branch information
Showing
14 changed files
with
578 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { page } from '../config/setup-playwright'; | ||
|
||
beforeEach(async () => { | ||
await page.click('[data-testid=LinkComponent]'); | ||
}); | ||
|
||
it('loads the article page', async () => { | ||
expect(await page.evaluate(() => location.pathname + location.search)).toBe( | ||
'/link-component/Article?author=Gandalf' | ||
); | ||
expect( | ||
((await page.accessibility.snapshot()) as any)?.children?.find( | ||
(it: any) => it.role === 'heading' | ||
)?.name | ||
).toBe('Article by Gandalf'); | ||
}); | ||
|
||
it('goes to the album page and goes back', async () => { | ||
await page.click('[href="/link-component/Album"]'); | ||
|
||
expect(await page.evaluate(() => location.pathname + location.search)).toBe( | ||
'/link-component/Album' | ||
); | ||
|
||
expect( | ||
((await page.accessibility.snapshot()) as any)?.children?.find( | ||
(it: any) => it.role === 'heading' | ||
)?.name | ||
).toBe('Album'); | ||
|
||
await page.click('[aria-label="Article by Gandalf, back"]'); | ||
|
||
await page.waitForNavigation(); | ||
|
||
expect(await page.evaluate(() => location.pathname + location.search)).toBe( | ||
'/link-component/Article?author=Gandalf' | ||
); | ||
|
||
expect( | ||
((await page.accessibility.snapshot()) as any)?.children?.find( | ||
(it: any) => it.role === 'heading' | ||
)?.name | ||
).toBe('Article by Gandalf'); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { page } from '../config/setup-playwright'; | ||
|
||
it('loads the example app', async () => { | ||
const snapshot = await page.accessibility.snapshot(); | ||
|
||
// @ts-ignore | ||
expect(snapshot?.children?.find((it) => it.role === 'heading')?.name).toBe( | ||
'Examples' | ||
); | ||
const title = await page.$eval('[role=heading]', (el) => el.textContent); | ||
|
||
expect(title).toBe('Examples'); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-env jest */ | ||
|
||
import { chromium, Browser, BrowserContext, Page } from 'playwright'; | ||
|
||
let browser: Browser; | ||
let context: BrowserContext; | ||
let page: Page; | ||
|
||
beforeAll(async () => { | ||
browser = await chromium.launch(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await browser.close(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
context = await browser.newContext(); | ||
page = await context.newPage(); | ||
|
||
await page.goto('http://localhost:3579'); | ||
}); | ||
|
||
export { browser, context, page }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { setup } from 'jest-dev-server'; | ||
|
||
export default async function () { | ||
await setup({ | ||
command: 'yarn serve -l 3579 web-build', | ||
port: 3579, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { teardown } from 'jest-dev-server'; | ||
|
||
export default async function () { | ||
await teardown(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
testRegex: '/__integration_tests__/.*\\.(test|spec)\\.(js|tsx?)$', | ||
globalSetup: './e2e/config/setup-server.tsx', | ||
globalTeardown: './e2e/config/teardown-server.tsx', | ||
setupFilesAfterEnv: ['./e2e/config/setup-playwright.tsx'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.