Skip to content

Commit 438df0f

Browse files
committed
node integration tests assert on equals, not objectContaining
1 parent ee58b92 commit 438df0f

File tree

2 files changed

+169
-165
lines changed
  • dev-packages
    • node-core-integration-tests/suites/public-api/logs
    • node-integration-tests/suites/public-api/logger

2 files changed

+169
-165
lines changed

dev-packages/node-core-integration-tests/suites/public-api/logs/test.ts

Lines changed: 105 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -9,112 +9,114 @@ describe('logger public API', () => {
99
test('captures logs with custom scopes and parameters in different forms', async () => {
1010
const runner = createRunner(__dirname, 'subject.ts')
1111
.expect({
12-
log: {
13-
items: [
14-
{
15-
attributes: {
16-
foo: {
17-
type: 'string',
18-
value: 'bar1',
19-
},
20-
'sentry.sdk.name': {
21-
type: 'string',
22-
value: 'sentry.javascript.node',
23-
},
24-
'sentry.sdk.version': {
25-
type: 'string',
26-
value: expect.any(String),
27-
},
28-
'server.address': {
29-
type: 'string',
30-
value: 'M6QX4Q5HKV.local',
31-
},
32-
'user.name': {
33-
type: 'string',
34-
value: 'h4cktor',
35-
},
12+
log: logsContainer => {
13+
expect(logsContainer).toEqual({
14+
items: [
15+
{
16+
attributes: {
17+
foo: {
18+
type: 'string',
19+
value: 'bar1',
20+
},
21+
'sentry.sdk.name': {
22+
type: 'string',
23+
value: 'sentry.javascript.node',
24+
},
25+
'sentry.sdk.version': {
26+
type: 'string',
27+
value: expect.any(String),
28+
},
29+
'server.address': {
30+
type: 'string',
31+
value: 'M6QX4Q5HKV.local',
32+
},
33+
'user.name': {
34+
type: 'string',
35+
value: 'h4cktor',
36+
},
37+
},
38+
body: 'test info',
39+
level: 'info',
40+
severity_number: 9,
41+
timestamp: expect.any(Number),
42+
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
3643
},
37-
body: 'test info',
38-
level: 'info',
39-
severity_number: 9,
40-
timestamp: expect.any(Number),
41-
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
42-
},
43-
{
44-
attributes: {
45-
foo: {
46-
type: 'string',
47-
value: 'bar2',
48-
},
49-
'sentry.message.parameter.0': {
50-
type: 'integer',
51-
value: 1,
52-
},
53-
'sentry.message.template': {
54-
type: 'string',
55-
value: 'test info with %d',
56-
},
57-
'sentry.sdk.name': {
58-
type: 'string',
59-
value: 'sentry.javascript.node',
60-
},
61-
'sentry.sdk.version': {
62-
type: 'string',
63-
value: expect.any(String),
64-
},
65-
'server.address': {
66-
type: 'string',
67-
value: 'M6QX4Q5HKV.local',
68-
},
69-
'user.name': {
70-
type: 'string',
71-
value: 'h4cktor',
72-
},
44+
{
45+
attributes: {
46+
foo: {
47+
type: 'string',
48+
value: 'bar2',
49+
},
50+
'sentry.message.parameter.0': {
51+
type: 'integer',
52+
value: 1,
53+
},
54+
'sentry.message.template': {
55+
type: 'string',
56+
value: 'test info with %d',
57+
},
58+
'sentry.sdk.name': {
59+
type: 'string',
60+
value: 'sentry.javascript.node',
61+
},
62+
'sentry.sdk.version': {
63+
type: 'string',
64+
value: expect.any(String),
65+
},
66+
'server.address': {
67+
type: 'string',
68+
value: 'M6QX4Q5HKV.local',
69+
},
70+
'user.name': {
71+
type: 'string',
72+
value: 'h4cktor',
73+
},
74+
},
75+
body: 'test info with 1',
76+
level: 'info',
77+
severity_number: 9,
78+
timestamp: expect.any(Number),
79+
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
7380
},
74-
body: 'test info with 1',
75-
level: 'info',
76-
severity_number: 9,
77-
timestamp: expect.any(Number),
78-
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
79-
},
80-
{
81-
attributes: {
82-
foo: {
83-
type: 'string',
84-
value: 'bar3',
85-
},
86-
'sentry.message.parameter.0': {
87-
type: 'integer',
88-
value: 1,
89-
},
90-
'sentry.message.template': {
91-
type: 'string',
92-
value: 'test info with fmt %s',
93-
},
94-
'sentry.sdk.name': {
95-
type: 'string',
96-
value: 'sentry.javascript.node',
97-
},
98-
'sentry.sdk.version': {
99-
type: 'string',
100-
value: expect.any(String),
101-
},
102-
'server.address': {
103-
type: 'string',
104-
value: 'M6QX4Q5HKV.local',
105-
},
106-
'user.name': {
107-
type: 'string',
108-
value: 'h4cktor',
109-
},
81+
{
82+
attributes: {
83+
foo: {
84+
type: 'string',
85+
value: 'bar3',
86+
},
87+
'sentry.message.parameter.0': {
88+
type: 'integer',
89+
value: 1,
90+
},
91+
'sentry.message.template': {
92+
type: 'string',
93+
value: 'test info with fmt %s',
94+
},
95+
'sentry.sdk.name': {
96+
type: 'string',
97+
value: 'sentry.javascript.node',
98+
},
99+
'sentry.sdk.version': {
100+
type: 'string',
101+
value: expect.any(String),
102+
},
103+
'server.address': {
104+
type: 'string',
105+
value: 'M6QX4Q5HKV.local',
106+
},
107+
'user.name': {
108+
type: 'string',
109+
value: 'h4cktor',
110+
},
111+
},
112+
body: 'test info with fmt 1',
113+
level: 'info',
114+
severity_number: 9,
115+
timestamp: expect.any(Number),
116+
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
110117
},
111-
body: 'test info with fmt 1',
112-
level: 'info',
113-
severity_number: 9,
114-
timestamp: expect.any(Number),
115-
trace_id: expect.stringMatching(/^[\da-f]{32}$/),
116-
},
117-
],
118+
],
119+
});
118120
},
119121
})
120122
.start();

dev-packages/node-integration-tests/suites/public-api/logger/test.ts

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -33,73 +33,75 @@ describe('logs', () => {
3333
test('captures logs with scope and log attributes', async () => {
3434
const runner = createRunner(__dirname, 'scenario.ts')
3535
.expect({
36-
log: {
37-
items: [
38-
{
39-
timestamp: expect.any(Number),
40-
level: 'info',
41-
body: 'log_before_any_scope',
42-
severity_number: 9,
43-
trace_id: expect.any(String),
44-
attributes: {
45-
...commonAttributes,
46-
log_attr: { value: 'log_attr_1', type: 'string' },
36+
log: logsContainer => {
37+
expect(logsContainer).toEqual({
38+
items: [
39+
{
40+
timestamp: expect.any(Number),
41+
level: 'info',
42+
body: 'log_before_any_scope',
43+
severity_number: 9,
44+
trace_id: expect.any(String),
45+
attributes: {
46+
...commonAttributes,
47+
log_attr: { value: 'log_attr_1', type: 'string' },
48+
},
4749
},
48-
},
49-
{
50-
timestamp: expect.any(Number),
51-
level: 'info',
52-
body: 'log_after_global_scope',
53-
severity_number: 9,
54-
trace_id: expect.any(String),
55-
attributes: {
56-
...commonAttributes,
57-
global_scope_attr: { value: true, type: 'boolean' },
58-
log_attr: { value: 'log_attr_2', type: 'string' },
50+
{
51+
timestamp: expect.any(Number),
52+
level: 'info',
53+
body: 'log_after_global_scope',
54+
severity_number: 9,
55+
trace_id: expect.any(String),
56+
attributes: {
57+
...commonAttributes,
58+
global_scope_attr: { value: true, type: 'boolean' },
59+
log_attr: { value: 'log_attr_2', type: 'string' },
60+
},
5961
},
60-
},
61-
{
62-
timestamp: expect.any(Number),
63-
level: 'info',
64-
body: 'log_with_isolation_scope',
65-
severity_number: 9,
66-
trace_id: expect.any(String),
67-
attributes: {
68-
...commonAttributes,
69-
global_scope_attr: { value: true, type: 'boolean' },
70-
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
71-
log_attr: { value: 'log_attr_3', type: 'string' },
62+
{
63+
timestamp: expect.any(Number),
64+
level: 'info',
65+
body: 'log_with_isolation_scope',
66+
severity_number: 9,
67+
trace_id: expect.any(String),
68+
attributes: {
69+
...commonAttributes,
70+
global_scope_attr: { value: true, type: 'boolean' },
71+
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
72+
log_attr: { value: 'log_attr_3', type: 'string' },
73+
},
7274
},
73-
},
74-
{
75-
timestamp: expect.any(Number),
76-
level: 'info',
77-
body: 'log_with_scope',
78-
severity_number: 9,
79-
trace_id: expect.any(String),
80-
attributes: {
81-
...commonAttributes,
82-
global_scope_attr: { value: true, type: 'boolean' },
83-
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
84-
scope_attr: { value: 200, unit: 'millisecond', type: 'integer' },
85-
log_attr: { value: 'log_attr_4', type: 'string' },
75+
{
76+
timestamp: expect.any(Number),
77+
level: 'info',
78+
body: 'log_with_scope',
79+
severity_number: 9,
80+
trace_id: expect.any(String),
81+
attributes: {
82+
...commonAttributes,
83+
global_scope_attr: { value: true, type: 'boolean' },
84+
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
85+
scope_attr: { value: 200, unit: 'millisecond', type: 'integer' },
86+
log_attr: { value: 'log_attr_4', type: 'string' },
87+
},
8688
},
87-
},
88-
{
89-
timestamp: expect.any(Number),
90-
level: 'info',
91-
body: 'log_with_scope_2',
92-
severity_number: 9,
93-
trace_id: expect.any(String),
94-
attributes: {
95-
...commonAttributes,
96-
global_scope_attr: { value: true, type: 'boolean' },
97-
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
98-
scope_2_attr: { value: 300, unit: 'millisecond', type: 'integer' },
99-
log_attr: { value: 'log_attr_5', type: 'string' },
89+
{
90+
timestamp: expect.any(Number),
91+
level: 'info',
92+
body: 'log_with_scope_2',
93+
severity_number: 9,
94+
trace_id: expect.any(String),
95+
attributes: {
96+
...commonAttributes,
97+
global_scope_attr: { value: true, type: 'boolean' },
98+
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
99+
scope_2_attr: { value: 300, unit: 'millisecond', type: 'integer' },
100+
log_attr: { value: 'log_attr_5', type: 'string' },
101+
},
100102
},
101-
},
102-
],
103+
],
104+
});
103105
},
104106
})
105107
.start();

0 commit comments

Comments
 (0)