Skip to content

Commit

Permalink
Re-enable pre Node 16 tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Oct 15, 2024
1 parent 93b2831 commit fcf3106
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
import { conditionalTest } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

afterAll(() => {
cleanupChildProcesses();
});

// Before Node 16, parametrization is not working properly here
conditionalTest({ min: 16 })('complex-router', () => {
describe('complex-router', () => {
test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route', done => {
// parse node.js major version
const [major = 0] = process.versions.node.split('.').map(Number);
// Split test result base on major node version because regex d flag is support from node 16+

const EXPECTED_TRANSACTION =
major >= 16
? {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
}
: {
transaction: 'GET /api/api/v1/sub-router/users/123/posts/:postId',
transaction_info: {
source: 'route',
},
};
const EXPECTED_TRANSACTION = {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
};

createRunner(__dirname, 'server.ts')
.ignore('event')
Expand All @@ -35,23 +21,12 @@ conditionalTest({ min: 16 })('complex-router', () => {
});

test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url has query params', done => {
// parse node.js major version
const [major = 0] = process.versions.node.split('.').map(Number);
// Split test result base on major node version because regex d flag is support from node 16+
const EXPECTED_TRANSACTION =
major >= 16
? {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
}
: {
transaction: 'GET /api/api/v1/sub-router/users/123/posts/:postId',
transaction_info: {
source: 'route',
},
};
const EXPECTED_TRANSACTION = {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
};

createRunner(__dirname, 'server.ts')
.ignore('event')
Expand All @@ -61,23 +36,12 @@ conditionalTest({ min: 16 })('complex-router', () => {
});

test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url ends with trailing slash and has query params', done => {
// parse node.js major version
const [major = 0] = process.versions.node.split('.').map(Number);
// Split test result base on major node version because regex d flag is support from node 16+
const EXPECTED_TRANSACTION =
major >= 16
? {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
}
: {
transaction: 'GET /api/api/v1/sub-router/users/123/posts/:postId',
transaction_info: {
source: 'route',
},
};
const EXPECTED_TRANSACTION = {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
};

createRunner(__dirname, 'server.ts')
.ignore('event')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
import { conditionalTest } from '../../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

afterAll(() => {
cleanupChildProcesses();
});

// Before Node 16, parametrization is not working properly here
conditionalTest({ min: 16 })('middle-layer-parameterized', () => {
describe('middle-layer-parameterized', () => {
test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route', done => {
// parse node.js major version
const [major = 0] = process.versions.node.split('.').map(Number);
// Split test result base on major node version because regex d flag is support from node 16+
const EXPECTED_TRANSACTION =
major >= 16
? {
transaction: 'GET /api/v1/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
}
: {
transaction: 'GET /api/v1/users/123/posts/:postId',
transaction_info: {
source: 'route',
},
};
const EXPECTED_TRANSACTION = {
transaction: 'GET /api/v1/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
};

createRunner(__dirname, 'server.ts')
.ignore('event')
Expand Down

0 comments on commit fcf3106

Please sign in to comment.