Skip to content

Commit e21fe4f

Browse files
committed
test(integration): Add support for snapshots in integration tests
* adds `yarn test:update-snapshots` script to update snapshots easily. This will run tests across all browsers and update the snapshots accordingly.
1 parent ee301c3 commit e21fe4f

File tree

7 files changed

+767
-253
lines changed

7 files changed

+767
-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 --scope=@sentry-internal/browser-integration-test 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
@@ -25,7 +25,8 @@
2525
"test:bundle:es6:min": "PW_BUNDLE=bundle_es6_min yarn test",
2626
"test:cjs": "PW_BUNDLE=cjs yarn test",
2727
"test:esm": "PW_BUNDLE=esm yarn test",
28-
"test:ci": "playwright test ./suites --browser='all' --reporter='line'"
28+
"test:ci": "playwright test ./suites --browser='all' --reporter='line'",
29+
"test:update-snapshots": "yarn test --update-snapshots --browser='all'"
2930
},
3031
"dependencies": {
3132
"@babel/preset-typescript": "^7.16.7",

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

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

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

0 commit comments

Comments
 (0)