Skip to content

Commit

Permalink
chore: add _debug and _setUnderTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ruifigueira committed Nov 5, 2023
1 parent f12aded commit e5d04ba
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/recorder-crx/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import type { CrxApplication } from 'playwright-crx';
import { crx } from 'playwright-crx';
import { crx, _debug, _setUnderTest } from 'playwright-crx';

// we must lazy initialize it
let crxAppPromise: Promise<CrxApplication> | undefined;
Expand Down Expand Up @@ -101,4 +101,4 @@ chrome.contextMenus.onClicked.addListener(async (_, tab) => {
});

// for testing
Object.assign(self, { attach });
Object.assign(self, { attach, _debug, _setUnderTest });
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ import type { Crx } from './src/types/types';
export * from './src/types/types';

export const crx: Crx;
export function _setUnderTest(): void;
export const _debug: {
enable(namespaces: string): void;
enabled(namespaces: string): boolean;
disable(): void;
};
33 changes: 19 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"debug": "^4.3.4",
"events": "^3.3.0",
"expect-bundle": "file:./playwright/packages/playwright/bundles/expect",
"https-browserify": "^1.0.0",
Expand All @@ -79,6 +80,7 @@
},
"devDependencies": {
"@types/chrome": "^0.0.246",
"@types/debug": "^4.1.10",
"@vitejs/plugin-react": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import type { CrxPlaywright as CrxPlaywrightAPI } from './client/crxPlaywright';
import { CrxPlaywright } from './server/crxPlaywright';
import { CrxPlaywrightDispatcher } from './server/dispatchers/crxPlaywrightDispatcher';

export { debug as _debug } from 'debug';
export { setUnderTest as _setUnderTest } from 'playwright-core/lib/utils';

const playwright = new CrxPlaywright();

const clientConnection = new CrxConnection();
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default defineConfig({
'chokidar': path.resolve(__dirname, './src/shims/chokidar'),
'constants': path.resolve(__dirname, './node_modules/constants-browserify'),
'crypto': path.resolve(__dirname, './node_modules/crypto-browserify'),
'debug': path.resolve(__dirname, './node_modules/debug'),
'dns': path.resolve(__dirname, './src/shims/dns'),
'events': path.resolve(__dirname, './node_modules/events'),
'fs': path.resolve(__dirname, './src/shims/fs'),
Expand Down

0 comments on commit e5d04ba

Please sign in to comment.