forked from ruifigueira/playwright-crx
-
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.
Merge pull request ruifigueira#4 from ruifigueira/feat/player
Feature: player
- Loading branch information
Showing
33 changed files
with
1,331 additions
and
420 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# text files must be lf for golden file tests to work | ||
* text=auto eol=lf | ||
# make project show as TS on GitHub | ||
*.js linguist-detectable=false |
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,46 @@ | ||
# Contributing | ||
|
||
## Tests | ||
|
||
We use playwright to test playwright-crx. | ||
|
||
The `context` fixture is extended to load a `playwright-crx` extension (e.g., recorder-crx or test-entension) | ||
|
||
### Run tests in extension service worker | ||
|
||
To run tests in our `test-extension` just use `crxTest.ts` and use the `runCrxTest` with your test function. | ||
|
||
It will run the function inside the extension: | ||
|
||
```ts | ||
import { test } from './crxTest'; | ||
|
||
test('should add todo item', async ({ runCrxTest }) => { | ||
await runCrxTest(async ({ page }) => { | ||
await page.goto('https://demo.playwright.dev/todomvc'); | ||
|
||
await page.getByPlaceholder('What needs to be done?').fill('Hello world'); | ||
await page.getByPlaceholder('What needs to be done?').press('Enter'); | ||
}); | ||
}); | ||
``` | ||
|
||
### Debug | ||
|
||
Debugging an extension service worker requires opening its service worker devtools. | ||
|
||
That can be done in `chrome://extensions` but to avoid lots of clicks and to allow test debugging, you can use the `_extensionServiceWorkerDevtools` fixture. | ||
|
||
This fixture will open the extension devtools and set a `debugger` instruction for the debugger to pause before running the test. | ||
|
||
That way, you can set all necessary breakpoints before continuing the execution. | ||
|
||
Here is an example using both `runCrxTest` and `_extensionServiceWorkerDevtools`: | ||
|
||
```ts | ||
test(`should debug`, async ({ runCrxTest, _extensionServiceWorkerDevtools }) => { | ||
await runCrxTest(async ({ crxApp, page /* other fixtures */ }) => { | ||
// code goes here | ||
}); | ||
}); | ||
``` |
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.