This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from WordPress/refactor-e2e-tests
Refactor e2e tests and add `goToFile` fixture
- Loading branch information
Showing
17 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions
7
e2e/directives-class.spec.ts → e2e/specs/directives-class.spec.ts
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
8 changes: 4 additions & 4 deletions
8
e2e/directives-context.spec.ts → e2e/specs/directives-context.spec.ts
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
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
7 changes: 3 additions & 4 deletions
7
e2e/tovdom-islands.spec.ts → e2e/specs/tovdom-islands.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { test as base, type Page } from '@playwright/test'; | ||
import { join } from 'path'; | ||
|
||
type Fixtures = { | ||
/** | ||
* Allow visiting local HTML files as if they were under a real domain, | ||
* mainly to avoid errors from `fetch` calls | ||
* | ||
* It looks for HTML files inside the `/e2e/html` folder, and uses | ||
* `Page.goto` under the hood. | ||
* | ||
* @example | ||
* ```ts | ||
* test.beforeEach(async ({ goToFile }) => { | ||
* await goToFile('directives-context.html'); | ||
* }); | ||
* ``` | ||
* | ||
* @param filename The name of the HTML file to visit. | ||
* @param options Same options object accepted by `page.goto`. | ||
* | ||
* @returns Promise. | ||
*/ | ||
goToFile: (...params: Parameters<Page['goto']>) => ReturnType<Page['goto']>; | ||
}; | ||
|
||
export const test = base.extend<Fixtures>({ | ||
goToFile: async ({ page }, use) => { | ||
await page.route('**/*.html', async (route, req) => { | ||
const { pathname } = new URL(req.url()); | ||
route.fulfill({ path: join(__dirname, './html', pathname) }); | ||
}); | ||
await page.route('**/*.js', async (route, req) => { | ||
const { pathname } = new URL(req.url()); | ||
route.fulfill({ path: join(__dirname, '..', pathname) }); | ||
}); | ||
|
||
await use(async (filename, options) => | ||
page.goto(join('http://a.b', filename), options) | ||
); | ||
}, | ||
}); | ||
|
||
export { expect } from '@playwright/test'; |