Skip to content

test(node): All integration tests now use the new runner #11341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
"fix": "eslint . --format stylish --fix",
"type-check": "tsc",
"pretest": "run-s --silent prisma:init",
"test": "ts-node ./utils/run-tests.ts",
"jest": "jest --config ./jest.config.js",
"test": "jest --config ./jest.config.js",
"test:watch": "yarn test --watch"
},
"dependencies": {
"@hapi/hapi": "^20.3.0",
"@nestjs/common": "^10.3.3",
"@nestjs/common": "^10.3.7",
"@nestjs/core": "^10.3.3",
"@nestjs/platform-express": "^10.3.3",
"@prisma/client": "5.9.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

Sentry.addBreadcrumb({});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

test('should add an empty breadcrumb, when an empty object is given', async () => {
const env = await TestEnv.init(__dirname);
const envelope = await env.getEnvelopeRequest();

expect(envelope).toHaveLength(3);
afterAll(() => {
cleanupChildProcesses();
});

assertSentryEvent(envelope[2], {
message: 'test-empty-obj',
});
test('should add an empty breadcrumb, when an empty object is given', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
message: 'test-empty-obj',
},
})
.start(done);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

Sentry.addBreadcrumb({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

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

assertSentryEvent(events[2], {
message: 'test_multi_breadcrumbs',
breadcrumbs: [
{
category: 'foo',
message: 'bar',
level: 'fatal',
},
{
category: 'qux',
test('should add multiple breadcrumbs', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
message: 'test_multi_breadcrumbs',
breadcrumbs: [
{
category: 'foo',
message: 'bar',
level: 'fatal',
},
{
category: 'qux',
},
],
},
],
});
})
.start(done);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

Sentry.addBreadcrumb({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { createRunner } from '../../../../utils/runner';

test('should add a simple breadcrumb', async () => {
const env = await TestEnv.init(__dirname);
const event = await env.getEnvelopeRequest();

assertSentryEvent(event[2], {
message: 'test_simple',
breadcrumbs: [
{
category: 'foo',
message: 'bar',
level: 'fatal',
test('should add a simple breadcrumb', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
message: 'test_simple',
breadcrumbs: [
{
category: 'foo',
message: 'bar',
level: 'fatal',
},
],
},
],
});
})
.start(done);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

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

assertSentryEvent(event[2], {
exception: {
values: [
{
type: 'Error',
value: 'catched_error',
mechanism: {
type: 'generic',
handled: true,
},
stacktrace: {
frames: expect.arrayContaining([
expect.objectContaining({
context_line: " throw new Error('catched_error');",
pre_context: [
'',
'Sentry.init({',
" dsn: 'https://[email protected]/1337',",
" release: '1.0',",
'});',
'',
'try {',
],
post_context: ['} catch (err) {', ' Sentry.captureException(err);', '}', ''],
}),
]),
},
test('should work inside catch block', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
exception: {
values: [
{
type: 'Error',
value: 'catched_error',
mechanism: {
type: 'generic',
handled: true,
},
stacktrace: {
frames: expect.arrayContaining([
expect.objectContaining({
context_line: " throw new Error('catched_error');",
pre_context: [
'Sentry.init({',
" dsn: 'https://[email protected]/1337',",
" release: '1.0',",
' transport: loggingTransport,',
'});',
'',
'try {',
],
post_context: ['} catch (err) {', ' Sentry.captureException(err);', '}', ''],
}),
]),
},
},
],
},
],
},
});
},
})
.start(done);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

Sentry.captureException({});
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

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

assertSentryEvent(event[2], {
exception: {
values: [
{
type: 'Error',
value: 'Object captured as exception with keys: [object has no keys]',
mechanism: {
type: 'generic',
handled: true,
},
test('should capture an empty object', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
exception: {
values: [
{
type: 'Error',
value: 'Object captured as exception with keys: [object has no keys]',
mechanism: {
type: 'generic',
handled: true,
},
},
],
},
],
},
});
},
})
.start(done);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

Sentry.captureException(new Error('test_simple_error'));
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

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

assertSentryEvent(envelope[2], {
exception: {
values: [
{
type: 'Error',
value: 'test_simple_error',
mechanism: {
type: 'generic',
handled: true,
},
stacktrace: {
frames: expect.any(Array),
},
test('should capture a simple error with message', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
exception: {
values: [
{
type: 'Error',
value: 'test_simple_error',
mechanism: {
type: 'generic',
handled: true,
},
stacktrace: {
frames: expect.any(Array),
},
},
],
},
],
},
});
},
})
.start(done);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

const x = 'first';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { TestEnv, assertSentryEvent } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

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

assertSentryEvent(event[2], {
logentry: {
message: 'This is a log statement with %s and %s params',
params: ['first', 'second'],
},
});
test('should capture a parameterized representation of the message', done => {
createRunner(__dirname, 'scenario.ts')
.expect({
event: {
logentry: {
message: 'This is a log statement with %s and %s params',
params: ['first', 'second'],
},
},
})
.start(done);
});
Loading