File tree Expand file tree Collapse file tree
apps/extension/features/steps Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { chromium , type BrowserContext } from "@playwright/test" ;
22import { test as base , createBdd } from 'playwright-bdd' ;
33import path from "path" ;
4+ import { APP_ID } from "../../common/config" ;
5+
46const pathToExtension = path . resolve ( ".output/chrome-mv3" ) ;
57
68type Fixtures = {
@@ -20,31 +22,8 @@ export const test = base.extend<Fixtures>({
2022 } ) ;
2123 await use ( context ) ;
2224 } ,
23- extensionId : async ( { context } , use ) => {
24- let background : { url ( ) : string } ;
25- if ( pathToExtension . endsWith ( "-mv3" ) ) {
26- const swPromise = context . waitForEvent ( "serviceworker" , { timeout : 120000 } ) ;
27- const serviceWorkers = context . serviceWorkers ( ) ;
28- if ( serviceWorkers . length > 0 ) {
29- background = serviceWorkers [ 0 ] ;
30- } else {
31- try {
32- background = await swPromise ;
33- } catch ( error ) {
34- throw new Error (
35- `Failed to load extension service worker within 60s. ` +
36- `Ensure extension is built (wxt build) and output exists at ${ pathToExtension } . ${ error } `
37- ) ;
38- }
39- }
40- } else {
41- [ background ] = context . backgroundPages ( ) ;
42- if ( ! background )
43- background = await context . waitForEvent ( "backgroundpage" ) ;
44- }
45-
46- const extensionId = background . url ( ) . split ( "/" ) [ 2 ] ;
47- await use ( extensionId ) ;
25+ extensionId : async ( { } , use ) => {
26+ await use ( APP_ID ) ;
4827 } ,
4928} ) ;
5029
You can’t perform that action at this time.
0 commit comments