Skip to content

Commit fee8740

Browse files
committed
Use Puppeteer Replay to stringify
1 parent b8d6066 commit fee8740

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
Testing Library Extension for Chrome DevTools Recorder
44

5+
## Installation
6+
7+
1. Clone the repo
8+
2. `npm install`
9+
3. `npm run build`
10+
4. Visit `chrome://extensions`
11+
5. Enable `Developer mode` via toggle switch in upper right corner
12+
6. Click `Load unpacked` button in upper left corner
13+
7. Select the `dist` directory
14+
15+
## Usage
16+
17+
1. Create a new recording via the Recorder panel.
18+
2. Hover over the export icon
19+
3. Click `Export as a Testing Library script`
20+
4. Save file as `{testName}.test.{ts.js}`
21+
522
## Inspiration
623

7-
- [Puppeteer Replay example extension](https://github.com/puppeteer/replay/tree/main/examples/chrome-extension)
24+
- [Puppeteer Replay examples](https://github.com/puppeteer/replay/tree/main/examples)

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { UserFlow } from "@puppeteer/replay"
1+
import { stringify, type UserFlow } from "@puppeteer/replay"
22

33
export class RecorderPlugin {
4-
async stringify(recording: UserFlow) {
5-
return JSON.stringify(recording, null, 2)
4+
stringify(recording: UserFlow) {
5+
return stringify(recording)
66
}
77
}
88

99
chrome.devtools.recorder.registerRecorderExtensionPlugin(
1010
new RecorderPlugin(),
1111
"Testing Library",
12-
"application/json",
12+
"application/javascript",
1313
)

webpack.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import webpack from "webpack"
12
import CopyPlugin from "copy-webpack-plugin"
23
import HtmlPlugin from "html-webpack-plugin"
34

5+
const { IgnorePlugin } = webpack
6+
47
export default {
58
module: {
69
rules: [
@@ -20,5 +23,8 @@ export default {
2023
patterns: ["manifest.json"],
2124
}),
2225
new HtmlPlugin(),
26+
new IgnorePlugin({
27+
resourceRegExp: /^puppeteer$/,
28+
}),
2329
],
2430
}

0 commit comments

Comments
 (0)