Skip to content

Commit 2c514ed

Browse files
authored
test(integration): Add support for snapshots in integration tests (#7145)
* adds `yarn test:update-snapshots` script to update snapshots easily. This will run tests across all browsers and update the snapshots accordingly.
1 parent a961e57 commit 2c514ed

File tree

8 files changed

+813
-253
lines changed

8 files changed

+813
-253
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"postpublish": "lerna run --stream --concurrency 1 postpublish",
2727
"test": "lerna run --ignore @sentry-internal/* test",
2828
"test-ci-browser": "lerna run test --ignore \"@sentry/{node,opentelemetry-node,serverless,nextjs,remix,gatsby}\" --ignore @sentry-internal/*",
29-
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts"
29+
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts",
30+
"test:update-snapshots": "lerna run test:update-snapshots"
3031
},
3132
"volta": {
3233
"node": "16.19.0",

packages/integration-tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"test:bundle:replay:es6:min": "PW_BUNDLE=bundle_replay_es6_min yarn test",
2828
"test:cjs": "PW_BUNDLE=cjs yarn test",
2929
"test:esm": "PW_BUNDLE=esm yarn test",
30-
"test:ci": "playwright test ./suites --browser='all' --reporter='line'"
30+
"test:ci": "playwright test ./suites --browser='all' --reporter='line'",
31+
"test:update-snapshots": "yarn test --update-snapshots --browser='all'"
3132
},
3233
"dependencies": {
3334
"@babel/preset-typescript": "^7.16.7",

packages/integration-tests/suites/replay/privacy/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<svg style="width:200px;height:200px" viewBox="0 0 80 80" data-sentry-unblock><path d=""/><area /><rect /></svg>
1212
<img style="width:100px;height:100px" src="file:///none.png" />
1313
<img data-sentry-unblock style="width:100px;height:100px" src="file:///none.png" />
14+
<video style="width:30px;height:30px"><source src="file://foo.mp4" /></video>
1415
</body>
1516
</html>

packages/integration-tests/suites/replay/privacy/test.ts

Lines changed: 1 addition & 251 deletions
Original file line numberDiff line numberDiff line change
@@ -27,255 +27,5 @@ sentryTest('should have the correct default privacy settings', async ({ getLocal
2727
const replayPayload = envelopeRequestParser<RecordingEvent[]>(await reqPromise0, 5);
2828
const checkoutEvent = replayPayload.find(({ type }) => type === EventType.FullSnapshot);
2929

30-
expect(checkoutEvent?.data).toEqual({
31-
node: {
32-
type: 0,
33-
childNodes: [
34-
{
35-
type: 1,
36-
name: 'html',
37-
publicId: '',
38-
systemId: '',
39-
id: 2,
40-
},
41-
{
42-
type: 2,
43-
tagName: 'html',
44-
attributes: {},
45-
childNodes: [
46-
{
47-
type: 2,
48-
tagName: 'head',
49-
attributes: {},
50-
childNodes: [
51-
{
52-
type: 2,
53-
tagName: 'meta',
54-
attributes: {
55-
charset: 'utf-8',
56-
},
57-
childNodes: [],
58-
id: 5,
59-
},
60-
],
61-
id: 4,
62-
},
63-
{
64-
type: 3,
65-
textContent: '\n ',
66-
id: 6,
67-
},
68-
{
69-
type: 2,
70-
tagName: 'body',
71-
attributes: {},
72-
childNodes: [
73-
{
74-
type: 3,
75-
textContent: '\n ',
76-
id: 8,
77-
},
78-
{
79-
type: 2,
80-
tagName: 'button',
81-
attributes: {
82-
'aria-label': '***** **',
83-
onclick: "console.log('Test log')",
84-
},
85-
childNodes: [
86-
{
87-
type: 3,
88-
textContent: '***** **',
89-
id: 10,
90-
},
91-
],
92-
id: 9,
93-
},
94-
{
95-
type: 3,
96-
textContent: '\n ',
97-
id: 11,
98-
},
99-
{
100-
type: 2,
101-
tagName: 'div',
102-
attributes: {},
103-
childNodes: [
104-
{
105-
type: 3,
106-
textContent: '**** ****** ** ****** ** *******',
107-
id: 13,
108-
},
109-
],
110-
id: 12,
111-
},
112-
{
113-
type: 3,
114-
textContent: '\n ',
115-
id: 14,
116-
},
117-
{
118-
type: 2,
119-
tagName: 'div',
120-
attributes: {
121-
'data-sentry-unmask': '',
122-
},
123-
childNodes: [
124-
{
125-
type: 3,
126-
textContent: 'This should be unmasked due to data attribute',
127-
id: 16,
128-
},
129-
],
130-
id: 15,
131-
},
132-
{
133-
type: 3,
134-
textContent: '\n ',
135-
id: 17,
136-
},
137-
{
138-
type: 2,
139-
tagName: 'input',
140-
attributes: {
141-
placeholder: '*********** ****** ** ******',
142-
},
143-
childNodes: [],
144-
id: 18,
145-
},
146-
{
147-
type: 3,
148-
textContent: '\n ',
149-
id: 19,
150-
},
151-
{
152-
type: 2,
153-
tagName: 'div',
154-
attributes: {
155-
title: '***** ****** ** ******',
156-
},
157-
childNodes: [
158-
{
159-
type: 3,
160-
textContent: '***** ****** ** ******',
161-
id: 21,
162-
},
163-
],
164-
id: 20,
165-
},
166-
{
167-
type: 3,
168-
textContent: '\n ',
169-
id: 22,
170-
},
171-
{
172-
type: 2,
173-
tagName: 'svg',
174-
attributes: {
175-
rr_width: '200px',
176-
rr_height: '200px',
177-
},
178-
childNodes: [],
179-
isSVG: true,
180-
id: 23,
181-
},
182-
{
183-
type: 3,
184-
textContent: '\n ',
185-
id: 24,
186-
},
187-
{
188-
type: 2,
189-
tagName: 'svg',
190-
attributes: {
191-
style: 'width:200px;height:200px',
192-
viewBox: '0 0 80 80',
193-
'data-sentry-unblock': '',
194-
},
195-
childNodes: [
196-
{
197-
type: 2,
198-
tagName: 'path',
199-
attributes: {
200-
d: '',
201-
},
202-
childNodes: [],
203-
isSVG: true,
204-
id: 26,
205-
},
206-
{
207-
type: 2,
208-
tagName: 'area',
209-
attributes: {},
210-
childNodes: [],
211-
isSVG: true,
212-
id: 27,
213-
},
214-
{
215-
type: 2,
216-
tagName: 'rect',
217-
attributes: {},
218-
childNodes: [],
219-
isSVG: true,
220-
id: 28,
221-
},
222-
],
223-
isSVG: true,
224-
id: 25,
225-
},
226-
{
227-
type: 3,
228-
textContent: '\n ',
229-
id: 29,
230-
},
231-
{
232-
type: 2,
233-
tagName: 'img',
234-
attributes: {
235-
rr_width: '100px',
236-
rr_height: '100px',
237-
},
238-
childNodes: [],
239-
id: 30,
240-
},
241-
{
242-
type: 3,
243-
textContent: '\n ',
244-
id: 31,
245-
},
246-
{
247-
type: 2,
248-
tagName: 'img',
249-
attributes: {
250-
'data-sentry-unblock': '',
251-
style: 'width:100px;height:100px',
252-
src: 'file:///none.png',
253-
},
254-
childNodes: [],
255-
id: 32,
256-
},
257-
{
258-
type: 3,
259-
textContent: '\n ',
260-
id: 33,
261-
},
262-
{
263-
type: 3,
264-
textContent: '\n\n',
265-
id: 34,
266-
},
267-
],
268-
id: 7,
269-
},
270-
],
271-
id: 3,
272-
},
273-
],
274-
id: 1,
275-
},
276-
initialOffset: {
277-
left: 0,
278-
top: 0,
279-
},
280-
});
30+
expect(JSON.stringify(checkoutEvent?.data, null, 2)).toMatchSnapshot('privacy.json');
28131
});

0 commit comments

Comments
 (0)