rrweb-browser-test 2.1.4 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/example/index.js DELETED
@@ -1,18 +0,0 @@
1
- import { generateBrowserTests, TestFramework } from '../dist/index.cjs';
2
- import events from '../events.json' with { type: 'json' };
3
-
4
- // console.log(generateBrowserTests(events));
5
- console.log(
6
- generateBrowserTests(events, {
7
- framework: TestFramework.CYPRESS,
8
- }),
9
- );
10
- // console.log(
11
- // generateBrowserTests(events, { framework: TestFramework.CYPRESS }),
12
- // );
13
- // console.log(
14
- // generateBrowserTests(events, { framework: TestFramework.SELENIUM }),
15
- // );
16
- // console.log(
17
- // generateBrowserTests(events, { framework: TestFramework.PUPPETEER }),
18
- // );
package/src/core.ts DELETED
@@ -1,31 +0,0 @@
1
- import type { eventWithTime } from '@rrweb/types';
2
- import { generateCypressTests } from './cypress';
3
- import { generatePlaywrightTests } from './playwright';
4
- import { generatePuppeteerTests } from './puppeteer';
5
- import { generateSeleniumTests } from './selenium';
6
- import { TestFramework, type TestOptions } from './types';
7
-
8
- const generateTests = (
9
- events: Array<eventWithTime | string>,
10
- options?: TestOptions,
11
- ): string => {
12
- switch (options?.framework) {
13
- case TestFramework.PLAYWRIGHT:
14
- return generatePlaywrightTests(events);
15
- case TestFramework.CYPRESS:
16
- return generateCypressTests(events);
17
- case TestFramework.SELENIUM:
18
- return generateSeleniumTests(events);
19
- case TestFramework.PUPPETEER:
20
- return generatePuppeteerTests(events);
21
- default:
22
- return generatePlaywrightTests(events);
23
- }
24
- };
25
-
26
- export const generateBrowserTests = (
27
- events: Array<eventWithTime | string>,
28
- options?: TestOptions,
29
- ): string => {
30
- return generateTests(events, options);
31
- };
@@ -1,126 +0,0 @@
1
- import {
2
- EventType,
3
- IncrementalSource,
4
- MouseInteractions,
5
- type eventWithTime,
6
- type fullSnapshotEvent,
7
- type inputData,
8
- type mediaInteractionData,
9
- type mouseInteractionData,
10
- type mousemoveData,
11
- type scrollData,
12
- type viewportResizeData,
13
- } from '@rrweb/types';
14
- import { buildNodeMapFromFullSnapshots, indent } from '../utils';
15
-
16
- export const generateCypressTests = (
17
- events: Array<eventWithTime | string>,
18
- ): string => {
19
- let code = '';
20
-
21
- code += `describe('TODO: name the test block', () => {\n`;
22
- code += ` it('TODO: name the test case', () => {\n`;
23
-
24
- const fullSnapshotEvents = events.filter(
25
- (event) => (event as eventWithTime).type === EventType.FullSnapshot,
26
- ) as fullSnapshotEvent[];
27
- const nodeMap = buildNodeMapFromFullSnapshots(fullSnapshotEvents);
28
-
29
- events.forEach((event: eventWithTime | string) => {
30
- const e = event as eventWithTime;
31
- switch (e.type) {
32
- case EventType.Meta:
33
- if (e.data.href) {
34
- code += `${indent(3)}cy.visit('${e.data.href}');\n`;
35
- code += `${indent(3)}cy.url().should('include', '${e.data.href}');\n`; // Assert URL after navigation
36
- }
37
- if (e.data.width && e.data.height) {
38
- code += `${indent(3)}cy.viewport(${e.data.width}, ${e.data.height});\n`;
39
- }
40
- break;
41
-
42
- case EventType.IncrementalSnapshot:
43
- const data = e.data;
44
- const type = data.source;
45
- let d;
46
- switch (type) {
47
- case IncrementalSource.MouseMove || IncrementalSource.TouchMove:
48
- d = data as mousemoveData;
49
- if (d.positions?.[0]?.x && d.positions?.[0]?.y) {
50
- code += `${indent(3)}cy.get('body').trigger('mousemove', { clientX: ${d.positions[0].x}, clientY: ${d.positions[0].y} });\n`;
51
- }
52
- break;
53
-
54
- case IncrementalSource.MouseInteraction:
55
- d = data as mouseInteractionData;
56
- if (d.type === MouseInteractions.Click) {
57
- const clickNode = nodeMap.get(d.id);
58
- const id = clickNode?.attributes?.id
59
- ? `#${clickNode?.attributes?.id}`
60
- : clickNode?.tagName === 'nav'
61
- ? `${clickNode?.tagName}:text-is("${clickNode.childNodes
62
- ?.filter((f) => f.tagName === 'a')
63
- ?.map((node) =>
64
- node.childNodes?.map(
65
- (n1) => (n1 as any)?.['textContent'],
66
- ),
67
- )
68
- .join(' ')}")`
69
- : clickNode?.tagName === 'a'
70
- ? `${clickNode?.tagName}:has-text("${clickNode.childNodes
71
- ?.map((node) => (node as any)?.['textContent'])
72
- .join(' ')}")`
73
- : clickNode !== undefined
74
- ? `${clickNode?.tagName}.${clickNode?.attributes?.class}`
75
- : undefined;
76
- if (id) {
77
- if (clickNode?.tagName === 'nav') {
78
- code += `${indent(3)}cy.contains('${clickNode?.tagName}', ${id}).click();\n`;
79
- } else {
80
- code += `${indent(3)}cy.get('${id}').click();\n`;
81
- }
82
- }
83
- }
84
- break;
85
-
86
- case IncrementalSource.Scroll:
87
- d = data as scrollData;
88
- if (d.x && d.y) {
89
- code += `${indent(3)}cy.get('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]').scrollTo(${d.x}, ${d.y});\n`;
90
- }
91
- break;
92
-
93
- case IncrementalSource.ViewportResize:
94
- d = data as viewportResizeData;
95
- if (d.width && d.height) {
96
- code += `${indent(3)}cy.viewport(${d.width}, ${d.height});\n`;
97
- }
98
- break;
99
-
100
- case IncrementalSource.Input:
101
- d = data as inputData;
102
- if (d.text) {
103
- code += `${indent(3)}cy.get('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]').type('${d.text}');\n`;
104
- code += `${indent(3)}cy.get('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]').should('have.value', '${d.text}');\n`; // Assert input value
105
- }
106
- break;
107
-
108
- case IncrementalSource.MediaInteraction:
109
- d = data as mediaInteractionData;
110
- if (d.type) {
111
- code += `${indent(3)}cy.get('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]').then((el) => el[0].${d.type}());\n`;
112
- }
113
- break;
114
- }
115
- break;
116
-
117
- default:
118
- break;
119
- }
120
- });
121
-
122
- code += ` });\n`;
123
- code += `});\n`;
124
-
125
- return code;
126
- };
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { TestFramework } from './types';
2
- export { generateBrowserTests } from './core';
@@ -1,130 +0,0 @@
1
- import {
2
- EventType,
3
- IncrementalSource,
4
- MouseInteractions,
5
- type eventWithTime,
6
- type fullSnapshotEvent,
7
- type inputData,
8
- type mediaInteractionData,
9
- type mouseInteractionData,
10
- type mousemoveData,
11
- type scrollData,
12
- type viewportResizeData,
13
- } from '@rrweb/types';
14
- import { buildNodeMapFromFullSnapshots, indent } from '../utils';
15
-
16
- export const generatePlaywrightTests = (
17
- events: Array<eventWithTime | string>,
18
- ): string => {
19
- let code = '';
20
-
21
- code += `import { test, expect } from '@playwright/test';\n\n`;
22
- code += `test('TODO: name the test block', async ({ page, context }) => {\n`;
23
-
24
- const fullSnapshotEvents = events.filter(
25
- (event) => (event as eventWithTime).type === EventType.FullSnapshot,
26
- ) as fullSnapshotEvent[];
27
- const nodeMap = buildNodeMapFromFullSnapshots(fullSnapshotEvents);
28
-
29
- code += `${indent(2)}const newTab = await context.newPage();\n`;
30
-
31
- events.forEach((event: eventWithTime | string) => {
32
- const e = event as eventWithTime;
33
- switch (e.type) {
34
- case EventType.Meta:
35
- if (e.data.href) {
36
- code += `${indent(2)}await page.goto('${e.data.href}');\n`;
37
- code += `${indent(2)}await expect(page).toHaveURL('${e.data.href}');\n`;
38
- }
39
- if (e.data.width && e.data.height) {
40
- code += `${indent(2)}await page.setViewportSize({ width: ${e.data.width}, height: ${e.data.height} });\n`;
41
- code += `${indent(2)}await expect(page).toHaveViewportSize({ width: ${e.data.width}, height: ${e.data.height} });\n`; // Assert viewport size
42
- }
43
- break;
44
-
45
- case EventType.IncrementalSnapshot:
46
- const data = e.data;
47
- const type = data.source;
48
- let d;
49
- switch (type) {
50
- case IncrementalSource.MouseMove || IncrementalSource.TouchMove:
51
- d = data as mousemoveData;
52
- if (d.positions?.[0]?.x && d.positions?.[0]?.y) {
53
- code += `${indent(2)}await page.mouse.move(${d.positions[0].x}, ${d.positions[0].y});\n`;
54
- }
55
- break;
56
-
57
- case IncrementalSource.MouseInteraction:
58
- d = data as mouseInteractionData;
59
- if (d.type === MouseInteractions.Click) {
60
- const clickNode = nodeMap.get(d.id);
61
- const id = clickNode?.attributes?.id
62
- ? `#${clickNode?.attributes?.id}`
63
- : clickNode?.tagName === 'nav'
64
- ? `${clickNode?.tagName}:text-is("${clickNode.childNodes
65
- ?.filter((f) => f.tagName === 'a')
66
- ?.map((node) =>
67
- node.childNodes?.map(
68
- (n1) => (n1 as any)?.['textContent'],
69
- ),
70
- )
71
- .join(' ')}")`
72
- : clickNode?.tagName === 'a'
73
- ? `${clickNode?.tagName}:has-text("${clickNode.childNodes
74
- ?.map((node) => (node as any)?.['textContent'])
75
- .join(' ')}")`
76
- : clickNode !== undefined
77
- ? `${clickNode?.tagName}.${clickNode?.attributes?.class}`
78
- : undefined;
79
-
80
- if (id && d.x && d.y) {
81
- code += `${indent(2)}await page.locator(\`${id}\`).click();\n`;
82
- code += `${indent(2)}await expect(page.locator(\`${id}\`)).toBeVisible();\n`; // Assert visibility after click
83
- }
84
- break;
85
- }
86
- break;
87
-
88
- case IncrementalSource.Scroll:
89
- d = data as scrollData;
90
- if (d.x && d.y) {
91
- code += `${indent(2)}await page.mouse.wheel(() => { document.querySelector('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]').scrollTo(${d.x}, ${d.y}); });\n`;
92
- code += `${indent(2)}await expect(page.locator('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]')).toBeVisible();\n`; // Assert element visibility after scroll
93
- }
94
- break;
95
-
96
- case IncrementalSource.ViewportResize:
97
- d = data as viewportResizeData;
98
- if (d.width && d.height) {
99
- code += `${indent(2)}await page.setViewportSize({ width: ${d.width}, height: ${d.height} });\n`;
100
- code += `${indent(2)}await expect(page).toHaveViewportSize({ width: ${d.width}, height: ${d.height} });\n`; // Assert viewport size
101
- }
102
- break;
103
-
104
- case IncrementalSource.Input:
105
- d = data as inputData;
106
- if (d.text) {
107
- code += `${indent(2)}await page.fill('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]', '${d.text}');\n`;
108
- code += `${indent(2)}await expect(page.locator('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]')).toHaveValue('${d.text}');\n`; // Assert input value
109
- }
110
- break;
111
-
112
- case IncrementalSource.MediaInteraction:
113
- d = data as mediaInteractionData;
114
- if (d.type) {
115
- code += `${indent(2)}await page.$eval('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]', el => el.${d.type}());\n`;
116
- code += `${indent(2)}await expect(page.locator('[data-id="${nodeMap.get(d.id)?.attributes?.id}"]')).toBeVisible();\n`; // Assert visibility of the media element
117
- }
118
- break;
119
- }
120
- break;
121
-
122
- default:
123
- break;
124
- }
125
- });
126
-
127
- code += `${indent(1)}});\n`;
128
-
129
- return code;
130
- };
@@ -1,139 +0,0 @@
1
- import {
2
- EventType,
3
- IncrementalSource,
4
- MouseInteractions,
5
- type eventWithTime,
6
- type fullSnapshotEvent,
7
- type inputData,
8
- type mediaInteractionData,
9
- type mouseInteractionData,
10
- type mousemoveData,
11
- type scrollData,
12
- type viewportResizeData,
13
- } from '@rrweb/types';
14
- import { buildNodeMapFromFullSnapshots, indent } from '../utils';
15
-
16
- export const generatePuppeteerTests = (
17
- events: Array<eventWithTime | string>,
18
- ): string => {
19
- let code = '';
20
-
21
- code += `const puppeteer = require('puppeteer');\n\n`;
22
- code += `describe('TODO: name the test block', () => {\n`;
23
- code += `${indent(1)}let browser, page;\n\n`;
24
- code += `${indent(1)}beforeAll(async () => {\n`;
25
- code += `${indent(2)}browser = await puppeteer.launch();\n`;
26
- code += `${indent(2)}page = await browser.newPage();\n`;
27
- code += `${indent(1)}});\n\n`;
28
- code += `${indent(1)}afterAll(async () => {\n`;
29
- code += `${indent(2)}await browser.close();\n`;
30
- code += `${indent(1)}});\n\n`;
31
-
32
- code += `${indent(1)}test('TODO: name the test case', async () => {\n`;
33
-
34
- const fullSnapshotEvents = events.filter(
35
- (event) => (event as eventWithTime).type === EventType.FullSnapshot,
36
- ) as fullSnapshotEvent[];
37
- const nodeMap = buildNodeMapFromFullSnapshots(fullSnapshotEvents);
38
-
39
- events.forEach((event: eventWithTime | string) => {
40
- const e = event as eventWithTime;
41
- switch (e.type) {
42
- case EventType.Meta:
43
- if (e.data.href) {
44
- code += `${indent(2)}await page.goto('${e.data.href}');\n`;
45
- code += `${indent(2)}await expect(page.url()).toBe('${e.data.href}');\n`;
46
- }
47
- if (e.data.width && e.data.height) {
48
- code += `${indent(2)}await page.setViewport({ width: ${e.data.width}, height: ${e.data.height} });\n`;
49
- }
50
- break;
51
-
52
- case EventType.IncrementalSnapshot:
53
- const data = e.data;
54
- const type = data.source;
55
- let d;
56
- switch (type) {
57
- case IncrementalSource.MouseMove || IncrementalSource.TouchMove:
58
- d = data as mousemoveData;
59
- if (d.positions?.[0]?.x && d.positions?.[0]?.y) {
60
- code += `${indent(2)}await page.mouse.move(${d.positions[0].x}, ${d.positions[0].y});\n`;
61
- }
62
- break;
63
-
64
- case IncrementalSource.MouseInteraction:
65
- d = data as mouseInteractionData;
66
- if (d.type === MouseInteractions.Click) {
67
- const clickNode = nodeMap.get(d.id);
68
- const id = clickNode?.attributes?.id
69
- ? `#${clickNode?.attributes?.id}`
70
- : clickNode?.tagName === 'nav'
71
- ? `${clickNode?.tagName}:text-is("${clickNode.childNodes
72
- ?.filter((f) => f.tagName === 'a')
73
- ?.map((node) =>
74
- node.childNodes?.map(
75
- (n1) => (n1 as any)?.['textContent'],
76
- ),
77
- )
78
- .join(' ')}")`
79
- : clickNode?.tagName === 'a'
80
- ? `${clickNode?.tagName}:has-text("${clickNode.childNodes
81
- ?.map((node) => (node as any)?.['textContent'])
82
- .join(' ')}")`
83
- : clickNode !== undefined
84
- ? `${clickNode?.tagName}.${clickNode?.attributes?.class}`
85
- : undefined;
86
-
87
- if (id) {
88
- code += `${indent(2)}await page.click('${id}');\n`;
89
- }
90
- }
91
- break;
92
-
93
- case IncrementalSource.Scroll:
94
- d = data as scrollData;
95
- if (d.x && d.y) {
96
- const elementId = nodeMap.get(d.id)?.attributes?.id || '';
97
- code += `${indent(2)}await page.evaluate(() => {\n`;
98
- code += `${indent(3)}document.querySelector('#${elementId}').scrollTo(${d.x}, ${d.y});\n`;
99
- code += `${indent(2)}});\n`;
100
- }
101
- break;
102
-
103
- case IncrementalSource.ViewportResize:
104
- d = data as viewportResizeData;
105
- if (d.width && d.height) {
106
- code += `${indent(2)}await page.setViewport({ width: ${d.width}, height: ${d.height} });\n`;
107
- }
108
- break;
109
-
110
- case IncrementalSource.Input:
111
- d = data as inputData;
112
- if (d.text) {
113
- const elementId = nodeMap.get(d.id)?.attributes?.id || '';
114
- code += `${indent(2)}await page.type('#${elementId}', '${d.text}');\n`;
115
- }
116
- break;
117
-
118
- case IncrementalSource.MediaInteraction:
119
- d = data as mediaInteractionData;
120
- if (d.type) {
121
- const elementId = nodeMap.get(d.id)?.attributes?.id || '';
122
- code += `${indent(2)}await page.evaluate(() => {\n`;
123
- code += `${indent(3)}document.querySelector('#${elementId}').${d.type}();\n`;
124
- code += `${indent(2)}});\n`;
125
- }
126
- break;
127
- }
128
- break;
129
-
130
- default:
131
- break;
132
- }
133
- });
134
-
135
- code += `${indent(1)}});\n`;
136
- code += `});\n`;
137
-
138
- return code;
139
- };
@@ -1,135 +0,0 @@
1
- import {
2
- EventType,
3
- IncrementalSource,
4
- MouseInteractions,
5
- type eventWithTime,
6
- type fullSnapshotEvent,
7
- type inputData,
8
- type mediaInteractionData,
9
- type mouseInteractionData,
10
- type mousemoveData,
11
- type scrollData,
12
- type viewportResizeData,
13
- } from '@rrweb/types';
14
- import { buildNodeMapFromFullSnapshots, indent } from '../utils';
15
-
16
- export const generateSeleniumTests = (
17
- events: Array<eventWithTime | string>,
18
- ): string => {
19
- let code = '';
20
-
21
- code += `const { Builder, By, until } = require('selenium-webdriver');\n\n`;
22
- code += `describe('TODO: name the test block', () => {\n`;
23
- code += `${indent(1)}let driver;\n\n`;
24
- code += `${indent(1)}beforeAll(async () => {\n`;
25
- code += `${indent(2)}driver = await new Builder().forBrowser('chrome').build();\n`;
26
- code += `${indent(1)}});\n\n`;
27
- code += `${indent(1)}afterAll(async () => {\n`;
28
- code += `${indent(2)}await driver.quit();\n`;
29
- code += `${indent(1)}});\n\n`;
30
-
31
- code += `${indent(1)}test('TODO: name the test case', async () => {\n`;
32
-
33
- const fullSnapshotEvents = events.filter(
34
- (event) => (event as eventWithTime).type === EventType.FullSnapshot,
35
- ) as fullSnapshotEvent[];
36
- const nodeMap = buildNodeMapFromFullSnapshots(fullSnapshotEvents);
37
-
38
- events.forEach((event: eventWithTime | string) => {
39
- const e = event as eventWithTime;
40
- switch (e.type) {
41
- case EventType.Meta:
42
- if (e.data.href) {
43
- code += `${indent(2)}await driver.get('${e.data.href}');\n`;
44
- code += `${indent(2)}await driver.wait(until.urlIs('${e.data.href}'), 5000);\n`; // Assert URL
45
- }
46
- if (e.data.width && e.data.height) {
47
- code += `${indent(2)}await driver.manage().window().setRect({ width: ${e.data.width}, height: ${e.data.height} });\n`;
48
- }
49
- break;
50
-
51
- case EventType.IncrementalSnapshot:
52
- const data = e.data;
53
- const type = data.source;
54
- let d;
55
- switch (type) {
56
- case IncrementalSource.MouseMove || IncrementalSource.TouchMove:
57
- d = data as mousemoveData;
58
- if (d.positions?.[0]?.x && d.positions?.[0]?.y) {
59
- code += `${indent(2)}await driver.actions().move({ x: ${d.positions[0].x}, y: ${d.positions[0].y} }).perform();\n`;
60
- }
61
- break;
62
-
63
- case IncrementalSource.MouseInteraction:
64
- d = data as mouseInteractionData;
65
- if (d.type === MouseInteractions.Click) {
66
- const clickNode = nodeMap.get(d.id);
67
- const id = clickNode?.attributes?.id
68
- ? `#${clickNode?.attributes?.id}`
69
- : clickNode?.tagName === 'nav'
70
- ? `${clickNode?.tagName}:text-is("${clickNode.childNodes
71
- ?.filter((f) => f.tagName === 'a')
72
- ?.map((node) =>
73
- node.childNodes?.map(
74
- (n1) => (n1 as any)?.['textContent'],
75
- ),
76
- )
77
- .join(' ')}")`
78
- : clickNode?.tagName === 'a'
79
- ? `${clickNode?.tagName}:has-text("${clickNode.childNodes
80
- ?.map((node) => (node as any)?.['textContent'])
81
- .join(' ')}")`
82
- : clickNode !== undefined
83
- ? `${clickNode?.tagName}.${clickNode?.attributes?.class}`
84
- : undefined;
85
- if (id) {
86
- code += `${indent(2)}await driver.findElement(By.css('${id}')).click();\n`;
87
- }
88
- }
89
- break;
90
-
91
- case IncrementalSource.Scroll:
92
- d = data as scrollData;
93
- if (d.x && d.y) {
94
- const elementId = nodeMap.get(d.id)?.attributes?.id || '';
95
- code += `${indent(2)}await driver.executeScript('document.querySelector("[id=${elementId}]").scrollTo(${d.x}, ${d.y});');\n`;
96
- }
97
- break;
98
-
99
- case IncrementalSource.ViewportResize:
100
- d = data as viewportResizeData;
101
- if (d.width && d.height) {
102
- code += `${indent(2)}await driver.manage().window().setRect({ width: ${d.width}, height: ${d.height} });\n`;
103
- }
104
- break;
105
-
106
- case IncrementalSource.Input:
107
- d = data as inputData;
108
- if (d.text) {
109
- const elementId = nodeMap.get(d.id)?.attributes?.id || '';
110
- code += `${indent(2)}const input = await driver.findElement(By.css('#${elementId}'));\n`;
111
- code += `${indent(2)}await input.clear();\n`;
112
- code += `${indent(2)}await input.sendKeys('${d.text}');\n`;
113
- }
114
- break;
115
-
116
- case IncrementalSource.MediaInteraction:
117
- d = data as mediaInteractionData;
118
- if (d.type) {
119
- const elementId = nodeMap.get(d.id)?.attributes?.id || '';
120
- code += `${indent(2)}await driver.executeScript('document.querySelector("[id=${elementId}]").${d.type}();');\n`;
121
- }
122
- break;
123
- }
124
- break;
125
-
126
- default:
127
- break;
128
- }
129
- });
130
-
131
- code += `${indent(1)}});\n`;
132
- code += `});\n`;
133
-
134
- return code;
135
- };
package/src/types.ts DELETED
@@ -1,17 +0,0 @@
1
- export type TestOptions = {
2
- framework: 'playwright' | 'puppeteer' | 'cypress' | 'selenium';
3
- };
4
-
5
- export type SerializedNodeWithId = {
6
- id: number;
7
- tagName?: string;
8
- attributes?: Record<string, any>;
9
- childNodes?: SerializedNodeWithId[];
10
- };
11
-
12
- export const TestFramework = {
13
- PLAYWRIGHT: 'playwright',
14
- PUPPETEER: 'puppeteer',
15
- CYPRESS: 'cypress',
16
- SELENIUM: 'selenium',
17
- };
package/src/utils.test.ts DELETED
@@ -1,6 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { indent } from './utils.js';
3
-
4
- test('add', () => {
5
- expect(indent(2)).toBe(' ');
6
- });
package/src/utils.ts DELETED
@@ -1,36 +0,0 @@
1
- import type { fullSnapshotEvent } from '@rrweb/types';
2
- import type { SerializedNodeWithId } from './types';
3
-
4
- export const indent = (level: number) => ' '.repeat(level);
5
- /**
6
- * Builds a map of all nodes by their IDs from a FullSnapshotEvent.
7
- * @param rootNode - The root node of the snapshot tree.
8
- * @returns A map where keys are node IDs and values are the corresponding nodes.
9
- */
10
- export const buildNodeMapFromFullSnapshots = (
11
- fullSnapshots: fullSnapshotEvent[],
12
- ): Map<number, SerializedNodeWithId> => {
13
- const idMap = new Map<number, SerializedNodeWithId>();
14
-
15
- // Iterate over each FullSnapshotEvent
16
- fullSnapshots.forEach((snapshot: fullSnapshotEvent) => {
17
- const rootNode = snapshot.data.node; // Get the root node of the full snapshot
18
-
19
- // Recursive function to process each node and add it to the map
20
- function processNode(node: SerializedNodeWithId) {
21
- idMap.set(node.id, node); // Add node to map using its ID
22
-
23
- // Recursively process child nodes, if any
24
- if (node.childNodes) {
25
- node.childNodes.forEach((childNode) => {
26
- processNode(childNode);
27
- });
28
- }
29
- }
30
-
31
- // Start the recursive node processing from the root node
32
- processNode(rootNode);
33
- });
34
-
35
- return idMap;
36
- };
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "esModuleInterop": true,
4
- "skipLibCheck": true,
5
- "target": "es2022",
6
- "allowJs": true,
7
- "resolveJsonModule": true,
8
- "moduleDetection": "force",
9
- "isolatedModules": true,
10
- "verbatimModuleSyntax": true,
11
-
12
- "strict": true,
13
- "noUncheckedIndexedAccess": true,
14
- "noImplicitOverride": true,
15
-
16
- "module": "Preserve",
17
- "lib": ["es2022"],
18
- "noEmit": true
19
- }
20
- }
package/tsup.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
-
3
- export default defineConfig({
4
- entryPoints: ['src/index.ts'],
5
- format: ['cjs', 'esm'],
6
- dts: true,
7
- outDir: 'dist',
8
- clean: true,
9
- });