Skip to content

Commit 1cd8290

Browse files
committed
test(node): All integration test using new runner
1 parent ae84d1a commit 1cd8290

File tree

59 files changed

+652
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+652
-656
lines changed

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
"fix": "eslint . --format stylish --fix",
2222
"type-check": "tsc",
2323
"pretest": "run-s --silent prisma:init",
24-
"test": "ts-node ./utils/run-tests.ts",
25-
"jest": "jest --config ./jest.config.js",
24+
"test": "jest --config ./jest.config.js",
2625
"test:watch": "yarn test --watch"
2726
},
2827
"dependencies": {

dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/empty-obj/scenario.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
Sentry.addBreadcrumb({});
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
22

3-
test('should add an empty breadcrumb, when an empty object is given', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const envelope = await env.getEnvelopeRequest();
6-
7-
expect(envelope).toHaveLength(3);
3+
afterAll(() => {
4+
cleanupChildProcesses();
5+
});
86

9-
assertSentryEvent(envelope[2], {
10-
message: 'test-empty-obj',
11-
});
7+
test('should add an empty breadcrumb, when an empty object is given', done => {
8+
createRunner(__dirname, 'scenario.ts')
9+
.expect({
10+
event: {
11+
message: 'test-empty-obj',
12+
},
13+
})
14+
.start(done);
1215
});

dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/multiple_breadcrumbs/scenario.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
Sentry.addBreadcrumb({
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
22

3-
test('should add multiple breadcrumbs', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const events = await env.getEnvelopeRequest();
3+
afterAll(() => {
4+
cleanupChildProcesses();
5+
});
66

7-
assertSentryEvent(events[2], {
8-
message: 'test_multi_breadcrumbs',
9-
breadcrumbs: [
10-
{
11-
category: 'foo',
12-
message: 'bar',
13-
level: 'fatal',
14-
},
15-
{
16-
category: 'qux',
7+
test('should add multiple breadcrumbs', done => {
8+
createRunner(__dirname, 'scenario.ts')
9+
.expect({
10+
event: {
11+
message: 'test_multi_breadcrumbs',
12+
breadcrumbs: [
13+
{
14+
category: 'foo',
15+
message: 'bar',
16+
level: 'fatal',
17+
},
18+
{
19+
category: 'qux',
20+
},
21+
],
1722
},
18-
],
19-
});
23+
})
24+
.start(done);
2025
});

dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/simple_breadcrumb/scenario.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
Sentry.addBreadcrumb({
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { createRunner } from '../../../../utils/runner';
22

3-
test('should add a simple breadcrumb', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const event = await env.getEnvelopeRequest();
6-
7-
assertSentryEvent(event[2], {
8-
message: 'test_simple',
9-
breadcrumbs: [
10-
{
11-
category: 'foo',
12-
message: 'bar',
13-
level: 'fatal',
3+
test('should add a simple breadcrumb', done => {
4+
createRunner(__dirname, 'scenario.ts')
5+
.expect({
6+
event: {
7+
message: 'test_simple',
8+
breadcrumbs: [
9+
{
10+
category: 'foo',
11+
message: 'bar',
12+
level: 'fatal',
13+
},
14+
],
1415
},
15-
],
16-
});
16+
})
17+
.start(done);
1718
});

dev-packages/node-integration-tests/suites/public-api/captureException/catched-error/scenario.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
try {
Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
22

3-
test('should work inside catch block', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const event = await env.getEnvelopeRequest();
3+
afterAll(() => {
4+
cleanupChildProcesses();
5+
});
66

7-
assertSentryEvent(event[2], {
8-
exception: {
9-
values: [
10-
{
11-
type: 'Error',
12-
value: 'catched_error',
13-
mechanism: {
14-
type: 'generic',
15-
handled: true,
16-
},
17-
stacktrace: {
18-
frames: expect.arrayContaining([
19-
expect.objectContaining({
20-
context_line: " throw new Error('catched_error');",
21-
pre_context: [
22-
'',
23-
'Sentry.init({',
24-
" dsn: 'https://[email protected]/1337',",
25-
" release: '1.0',",
26-
'});',
27-
'',
28-
'try {',
29-
],
30-
post_context: ['} catch (err) {', ' Sentry.captureException(err);', '}', ''],
31-
}),
32-
]),
33-
},
7+
test('should work inside catch block', done => {
8+
createRunner(__dirname, 'scenario.ts')
9+
.expect({
10+
event: {
11+
exception: {
12+
values: [
13+
{
14+
type: 'Error',
15+
value: 'catched_error',
16+
mechanism: {
17+
type: 'generic',
18+
handled: true,
19+
},
20+
stacktrace: {
21+
frames: expect.arrayContaining([
22+
expect.objectContaining({
23+
context_line: " throw new Error('catched_error');",
24+
pre_context: [
25+
'Sentry.init({',
26+
" dsn: 'https://[email protected]/1337',",
27+
" release: '1.0',",
28+
' transport: loggingTransport,',
29+
'});',
30+
'',
31+
'try {',
32+
],
33+
post_context: ['} catch (err) {', ' Sentry.captureException(err);', '}', ''],
34+
}),
35+
]),
36+
},
37+
},
38+
],
3439
},
35-
],
36-
},
37-
});
40+
},
41+
})
42+
.start(done);
3843
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
Sentry.captureException({});
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
22

3-
test('should capture an empty object', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const event = await env.getEnvelopeRequest();
3+
afterAll(() => {
4+
cleanupChildProcesses();
5+
});
66

7-
assertSentryEvent(event[2], {
8-
exception: {
9-
values: [
10-
{
11-
type: 'Error',
12-
value: 'Object captured as exception with keys: [object has no keys]',
13-
mechanism: {
14-
type: 'generic',
15-
handled: true,
16-
},
7+
test('should capture an empty object', done => {
8+
createRunner(__dirname, 'scenario.ts')
9+
.expect({
10+
event: {
11+
exception: {
12+
values: [
13+
{
14+
type: 'Error',
15+
value: 'Object captured as exception with keys: [object has no keys]',
16+
mechanism: {
17+
type: 'generic',
18+
handled: true,
19+
},
20+
},
21+
],
1722
},
18-
],
19-
},
20-
});
23+
},
24+
})
25+
.start(done);
2126
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
Sentry.captureException(new Error('test_simple_error'));
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
22

3-
test('should capture a simple error with message', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const envelope = await env.getEnvelopeRequest();
3+
afterAll(() => {
4+
cleanupChildProcesses();
5+
});
66

7-
assertSentryEvent(envelope[2], {
8-
exception: {
9-
values: [
10-
{
11-
type: 'Error',
12-
value: 'test_simple_error',
13-
mechanism: {
14-
type: 'generic',
15-
handled: true,
16-
},
17-
stacktrace: {
18-
frames: expect.any(Array),
19-
},
7+
test('should capture a simple error with message', done => {
8+
createRunner(__dirname, 'scenario.ts')
9+
.expect({
10+
event: {
11+
exception: {
12+
values: [
13+
{
14+
type: 'Error',
15+
value: 'test_simple_error',
16+
mechanism: {
17+
type: 'generic',
18+
handled: true,
19+
},
20+
stacktrace: {
21+
frames: expect.any(Array),
22+
},
23+
},
24+
],
2025
},
21-
],
22-
},
23-
});
26+
},
27+
})
28+
.start(done);
2429
});

dev-packages/node-integration-tests/suites/public-api/captureMessage/parameterized_message/scenario.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
const x = 'first';
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
import { TestEnv, assertSentryEvent } from '../../../../utils';
1+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
22

3-
test('should capture a parameterized representation of the message', async () => {
4-
const env = await TestEnv.init(__dirname);
5-
const event = await env.getEnvelopeRequest();
3+
afterAll(() => {
4+
cleanupChildProcesses();
5+
});
66

7-
assertSentryEvent(event[2], {
8-
logentry: {
9-
message: 'This is a log statement with %s and %s params',
10-
params: ['first', 'second'],
11-
},
12-
});
7+
test('should capture a parameterized representation of the message', done => {
8+
createRunner(__dirname, 'scenario.ts')
9+
.expect({
10+
event: {
11+
logentry: {
12+
message: 'This is a log statement with %s and %s params',
13+
params: ['first', 'second'],
14+
},
15+
},
16+
})
17+
.start(done);
1318
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
12
import * as Sentry from '@sentry/node';
23

34
Sentry.init({
45
dsn: 'https://[email protected]/1337',
56
release: '1.0',
7+
transport: loggingTransport,
68
});
79

810
Sentry.captureMessage('Message');

0 commit comments

Comments
 (0)