Skip to content
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
19 changes: 16 additions & 3 deletions packages/node-integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@ module.exports = {
jest: true,
},
extends: ['../../.eslintrc.js'],
parserOptions: {
sourceType: 'module',
},
overrides: [
{
files: ['utils/**/*.ts'],
parserOptions: {
project: ['tsconfig.json'],
sourceType: 'module',
},
},
{
files: ['suites/**/*.ts'],
parserOptions: {
project: ['tsconfig.test.json'],
sourceType: 'module',
},
},
],
};
2 changes: 1 addition & 1 deletion packages/node-integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const baseConfig = require('../../jest/jest.config.js');

module.exports = {
globalSetup: '<rootDir>/setup-tests.ts',
globalSetup: '<rootDir>/utils/setup-tests.ts',
...baseConfig,
testMatch: ['**/test.ts'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import http from 'http';

const app = express();

export type TestAPIResponse = { test_data: { host: string; 'sentry-trace': string } };

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { TRACEPARENT_REGEXP } from '@sentry/utils';
import * as path from 'path';

import { getAPIResponse, runServer } from '../../../../utils/index';
import path = require('path');
import { TestAPIResponse } from '../server';

test('Should assign `sentry-trace` header which sets parent trace id of an outgoing request.', async () => {
const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`);

const response = await getAPIResponse(new URL(`${url}/express`), {
const response = (await getAPIResponse(new URL(`${url}/express`), {
'sentry-trace': '12312012123120121231201212312012-1121201211212012-0',
});
})) as TestAPIResponse;

expect(response).toBeDefined();
expect(response).toMatchObject({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TRACEPARENT_REGEXP } from '@sentry/utils';
import * as path from 'path';

import { getAPIResponse, runServer } from '../../../../utils/index';
import path = require('path');
import { TestAPIResponse } from '../server';

test('should attach a `sentry-trace` header to an outgoing request.', async () => {
const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`);

const response = await getAPIResponse(new URL(`${url}/express`));
const response = (await getAPIResponse(new URL(`${url}/express`))) as TestAPIResponse;

expect(response).toBeDefined();
expect(response).toMatchObject({
Expand Down
2 changes: 1 addition & 1 deletion packages/node-integration-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",

"include": ["**/*.ts"],
"include": ["utils/**/*.ts"],

"compilerOptions": {
// package-specific options
Expand Down
2 changes: 1 addition & 1 deletion packages/node-integration-tests/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",

"include": ["**/*.ts"],
"include": ["suites/**/*.ts"],

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
Expand Down
4 changes: 2 additions & 2 deletions packages/node-integration-tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export const getMultipleEnvelopeRequest = async (url: string, count: number): Pr
* @param {Record<string, string>} [headers]
* @return {*} {Promise<any>}
*/
export const getAPIResponse = async (url: URL, headers?: Record<string, string>): Promise<any> => {
return await new Promise(resolve => {
export const getAPIResponse = async (url: URL, headers?: Record<string, string>): Promise<unknown> => {
return new Promise(resolve => {
http.get(
headers
? ({
Expand Down