Skip to content

Commit 2c95fcf

Browse files
twilio-product-securitysnyk-botVictor Ayogu
authored
[Snyk] Security upgrade jest from 28.1.3 to 29.0.0 (#491)
* fix: package.json to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-INFLIGHT-6095116 * fix: update snapshots and tests * fix: update config * fix: update typedoc --------- Co-authored-by: snyk-bot <snyk-bot@snyk.io> Co-authored-by: Victor Ayogu <vayogu@twilio.com>
1 parent 860cc52 commit 2c95fcf

File tree

12 files changed

+123
-105
lines changed

12 files changed

+123
-105
lines changed

jest.config.base.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ module.exports = {
1111
coverageDirectory: 'coverage',
1212

1313
// A set of global variables that need to be available in all test environments
14-
globals: {
15-
'ts-jest': {
16-
tsconfig: 'tsconfig.test.json',
17-
},
14+
transform: {
15+
'^.+\\.ts?$': [
16+
'ts-jest',
17+
{
18+
tsconfig: 'tsconfig.test.json',
19+
},
20+
],
1821
},
1922
// The test environment that will be used for testing
2023
testEnvironment: 'node',

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
"conventional-changelog-cli": "^2.1.0",
3535
"cz-conventional-changelog": "^2.1.0",
3636
"husky": "^8.0.2",
37-
"jest": "^28.1.3",
37+
"jest": "^29.7.0",
3838
"jest-express": "^1.10.1",
3939
"lint-staged": "^9.0.0",
4040
"npm-run-all": "^4.1.5",
4141
"prettier": "^2.2.1",
4242
"rimraf": "^3.0.2",
43-
"ts-jest": "^28.0.8",
43+
"ts-jest": "^29.1.2",
44+
"typedoc": "^0.25.12",
4445
"typescript": "^5.3.3"
4546
},
4647
"lint-staged": {

packages/create-twilio-function/tests/install-dependencies.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
const path = require('path');
2+
jest.mock('pkg-install');
23

34
const pkgInstall = require('pkg-install');
45

5-
const { installDependencies } = require('../src/create-twilio-function/install-dependencies');
6+
const {
7+
installDependencies,
8+
} = require('../src/create-twilio-function/install-dependencies');
69

710
const scratchDir = path.join(process.cwd(), 'scratch');
811

9-
jest.mock('pkg-install');
10-
1112
describe('installDependencies', () => {
1213
test('it calls `npm install` in the target directory', async () => {
1314
pkgInstall.projectInstall.mockResolvedValue({ stdout: 'done' });
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
jest.mock('pkg-install');
2+
jest.mock('window-size', () => ({ get: () => ({ width: 80 }) }));
3+
14
const pkgInstall = require('pkg-install');
25
const chalk = require('chalk');
36

47
const successMessage = require('../src/create-twilio-function/success-message');
58

6-
jest.mock('pkg-install');
7-
jest.mock('window-size', () => ({ get: () => ({ width: 80 }) }));
8-
99
describe('successMessage', () => {
1010
test('creates a success message based on the package manager', async () => {
1111
pkgInstall.getPackageManager.mockResolvedValue('yarn');
@@ -15,6 +15,10 @@ describe('successMessage', () => {
1515
};
1616
const message = await successMessage(config);
1717
expect(message).toEqual(expect.stringContaining('yarn start'));
18-
expect(message).toEqual(expect.stringContaining(chalk`Created {bold ${config.name}} at {bold ${config.path}}`));
18+
expect(message).toEqual(
19+
expect.stringContaining(
20+
chalk`Created {bold ${config.name}} at {bold ${config.path}}`
21+
)
22+
);
1923
});
2024
});

packages/create-twilio-function/tests/window-size.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const getWindowSize = require('../src/create-twilio-function/window-size');
2-
31
jest.mock('window-size', () => ({
42
get: jest
53
.fn()
@@ -16,6 +14,8 @@ jest.mock('window-size', () => ({
1614
}),
1715
}));
1816

17+
const getWindowSize = require('../src/create-twilio-function/window-size');
18+
1919
describe('getWindowSize', () => {
2020
it('gets a valid windowSize', () => {
2121
const windowSize = getWindowSize();

packages/plugin-assets/tests/init.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
const { init } = require('../src/init');
2-
const path = require('path');
3-
const fs = require('fs').promises;
4-
const { tmpdir } = require('os');
5-
6-
const {
7-
createService,
8-
} = require('@twilio-labs/serverless-api/dist/api/services');
9-
const {
10-
createEnvironmentFromSuffix,
11-
getEnvironment,
12-
} = require('@twilio-labs/serverless-api/dist/api/environments');
13-
141
jest.mock('@twilio-labs/serverless-api/dist/api/services', () => {
152
return { createService: jest.fn().mockResolvedValue('new-service-sid') };
163
});
@@ -25,6 +12,19 @@ jest.mock('@twilio-labs/serverless-api/dist/api/environments', () => {
2512
};
2613
});
2714

15+
const { init } = require('../src/init');
16+
const path = require('path');
17+
const fs = require('fs').promises;
18+
const { tmpdir } = require('os');
19+
20+
const {
21+
createService,
22+
} = require('@twilio-labs/serverless-api/dist/api/services');
23+
const {
24+
createEnvironmentFromSuffix,
25+
getEnvironment,
26+
} = require('@twilio-labs/serverless-api/dist/api/environments');
27+
2828
const mockLogger = {
2929
error: jest.fn(),
3030
debug: jest.fn(),

packages/runtime-handler/__tests__/dev-runtime/__snapshots__/integration.test.ts.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`with an express app with forked process function handling Function integration tests basic-twiml.js should match snapshot 1`] = `
4-
Object {
5-
"body": Object {},
6-
"headers": Object {
4+
{
5+
"body": {},
6+
"headers": {
77
"cache-control": "no-store, no-cache, must-revalidate, proxy-revalidate",
88
"connection": "close",
99
"content-type": "text/xml; charset=utf-8",
@@ -13,15 +13,15 @@ Object {
1313
"x-powered-by": "Express",
1414
},
1515
"statusCode": 200,
16-
"text": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Response><Message>Hello World</Message></Response>",
16+
"text": "<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello World</Message></Response>",
1717
"type": "text/xml",
1818
}
1919
`;
2020

2121
exports[`with an express app with inline function handling Assets integration tests hello.js should match snapshot 1`] = `
22-
Object {
23-
"body": Object {},
24-
"headers": Object {
22+
{
23+
"body": {},
24+
"headers": {
2525
"accept-ranges": "bytes",
2626
"cache-control": "no-store, no-cache, must-revalidate, proxy-revalidate",
2727
"connection": "close",
@@ -39,9 +39,9 @@ Object {
3939
`;
4040

4141
exports[`with an express app with inline function handling Assets integration tests index.html should match snapshot 1`] = `
42-
Object {
43-
"body": Object {},
44-
"headers": Object {
42+
{
43+
"body": {},
44+
"headers": {
4545
"accept-ranges": "bytes",
4646
"cache-control": "no-store, no-cache, must-revalidate, proxy-revalidate",
4747
"connection": "close",
@@ -58,9 +58,9 @@ Object {
5858
`;
5959

6060
exports[`with an express app with inline function handling Function integration tests basic-twiml.js should match snapshot 1`] = `
61-
Object {
62-
"body": Object {},
63-
"headers": Object {
61+
{
62+
"body": {},
63+
"headers": {
6464
"cache-control": "no-store, no-cache, must-revalidate, proxy-revalidate",
6565
"connection": "close",
6666
"content-type": "text/xml; charset=utf-8",
@@ -70,7 +70,7 @@ Object {
7070
"x-powered-by": "Express",
7171
},
7272
"statusCode": 200,
73-
"text": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Response><Message>Hello World</Message></Response>",
73+
"text": "<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello World</Message></Response>",
7474
"type": "text/xml",
7575
}
7676
`;

packages/runtime-handler/jest.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ const base = require('../../jest.config.base.js');
22

33
module.exports = {
44
...base,
5-
globals: {
6-
'ts-jest': {
7-
tsconfig: './tsconfig.test.json',
8-
},
5+
transform: {
6+
'^.+\\.ts?$': [
7+
'ts-jest',
8+
{
9+
tsconfig: './tsconfig.test.json',
10+
},
11+
],
912
},
1013
name: 'runtime-handler',
1114
displayName: 'runtime-handler',

packages/serverless-api/jest.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ const base = require('../../jest.config.base.js');
22

33
module.exports = {
44
...base,
5-
globals: {
6-
'ts-jest': {
7-
tsconfig: './tsconfig.test.json',
8-
},
5+
transform: {
6+
'^.+\\.ts?$': [
7+
'ts-jest',
8+
{
9+
tsconfig: './tsconfig.test.json',
10+
},
11+
],
912
},
1013
name: 'serverless-api',
1114
displayName: 'serverless-api',
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`with an express app with forked process function handling Function integration tests basic-twiml.js should match snapshot 1`] = `
4-
Object {
5-
"body": Object {},
6-
"headers": Object {
4+
{
5+
"body": {},
6+
"headers": {
77
"connection": "close",
88
"content-type": "text/xml; charset=utf-8",
99
"x-powered-by": "Express",
1010
},
1111
"statusCode": 200,
12-
"text": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Response><Message>Hello World</Message></Response>",
12+
"text": "<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello World</Message></Response>",
1313
"type": "text/xml",
1414
}
1515
`;
1616

1717
exports[`with an express app with inline function handling Assets integration tests hello.js should match snapshot 1`] = `
18-
Object {
19-
"body": Object {},
20-
"headers": Object {
18+
{
19+
"body": {},
20+
"headers": {
2121
"accept-ranges": "bytes",
2222
"cache-control": "public, max-age=0",
2323
"connection": "close",
@@ -32,15 +32,15 @@ Object {
3232
`;
3333

3434
exports[`with an express app with inline function handling Function integration tests basic-twiml.js should match snapshot 1`] = `
35-
Object {
36-
"body": Object {},
37-
"headers": Object {
35+
{
36+
"body": {},
37+
"headers": {
3838
"connection": "close",
3939
"content-type": "text/xml; charset=utf-8",
4040
"x-powered-by": "Express",
4141
},
4242
"statusCode": 200,
43-
"text": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?><Response><Message>Hello World</Message></Response>",
43+
"text": "<?xml version="1.0" encoding="UTF-8"?><Response><Message>Hello World</Message></Response>",
4444
"type": "text/xml",
4545
}
4646
`;

0 commit comments

Comments
 (0)