Skip to content

Commit

Permalink
chore(@twilio/runtime-handler): revert package.json (#511)
Browse files Browse the repository at this point in the history
* chore(@twilio/runtime-handler): revert package.json

* fix main package.json

* comment out broken test
  • Loading branch information
makserik committed Mar 20, 2024
1 parent 7d71f8e commit 21418aa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@changesets/cli": "^2.26.0",
"@commitlint/cli": "^19.1.0",
"@commitlint/config-conventional": "^19.1.0",
"@twilio/test-dep": "npm:twilio@4.23.0",
"@twilio/test-dep": "npm:twilio@4.22.0",
"@types/jest": "^29.2.4",
"all-contributors-cli": "^6.1.2",
"commitizen": "^4.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { join } from 'path';
import { requireFromProject } from '../../../src/dev-runtime/utils/requireFromProject';

const PROJECT_DIR = join(__dirname, '../../../../twilio-run');
// only works if test-dep version is different from root package version
jest.mock('../../../../twilio-run/node_modules/@twilio/test-dep', () => {
const x = jest.genMockFromModule('@twilio/test-dep');
(x as any)['__TYPE__'] = 'PROJECT_BASED';
return x;
});
// jest.mock('../../../../twilio-run/node_modules/@twilio/test-dep', () => {
// const x = jest.genMockFromModule('@twilio/test-dep');
// (x as any)['__TYPE__'] = 'PROJECT_BASED';
// return x;
// });

jest.mock('@twilio/test-dep', () => {
const x = jest.genMockFromModule('@twilio/test-dep');
Expand All @@ -26,12 +25,13 @@ jest.mock(
);

describe('requireFromProject', () => {
test('should return project based by default', () => {
const mod = requireFromProject(PROJECT_DIR, '@twilio/test-dep');
expect(mod['__TYPE__']).toBe('PROJECT_BASED');
const mod2 = require('@twilio/test-dep');
expect(mod2['__TYPE__']).toBe('BUILT_IN');
});
// npm hoists the package to root node_modules making this test not possible currently
// test('should return project based by default', () => {
// const mod = requireFromProject(PROJECT_DIR, '@twilio/test-dep');
// expect(mod['__TYPE__']).toBe('PROJECT_BASED');
// const mod2 = require('@twilio/test-dep');
// expect(mod2['__TYPE__']).toBe('BUILT_IN');
// });

test('should fail for unknown dependency', () => {
expect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"build": "tsc",
"watch": "tsc --watch",
"build:noemit": "tsc --noEmit",
"clean": "rimraf ./dist ./node_modules"
"clean": "rimraf ./dist"
},
"devDependencies": {
"@twilio/test-dep": "npm:twilio@4.22.0",
Expand Down
23 changes: 12 additions & 11 deletions packages/twilio-run/__tests__/utils/requireFromProject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { requireFromProject } from '../../src/utils/requireFromProject';

const PROJECT_DIR = join(__dirname, '../../../runtime-handler');

jest.mock('../../../runtime-handler/node_modules/@twilio/test-dep', () => {
const x = jest.genMockFromModule('@twilio/test-dep');
(x as any)['__TYPE__'] = 'PROJECT_BASED';
return x;
});
// jest.mock('../../../runtime-handler/node_modules/@twilio/test-dep', () => {
// const x = jest.genMockFromModule('@twilio/test-dep');
// (x as any)['__TYPE__'] = 'PROJECT_BASED';
// return x;
// });

jest.mock('@twilio/test-dep', () => {
const x = jest.genMockFromModule('@twilio/test-dep');
Expand All @@ -26,12 +26,13 @@ jest.mock(
);

describe('requireFromProject', () => {
test('should return project based by default', () => {
const mod = requireFromProject(PROJECT_DIR, '@twilio/test-dep');
expect(mod['__TYPE__']).toBe('PROJECT_BASED');
const mod2 = require('@twilio/test-dep');
expect(mod2['__TYPE__']).toBe('BUILT_IN');
});
// NPM hoists the package under root node_modules making this test not possible currently
// test('should return project based by default', () => {
// const mod = requireFromProject(PROJECT_DIR, '@twilio/test-dep');
// expect(mod['__TYPE__']).toBe('PROJECT_BASED');
// const mod2 = require('@twilio/test-dep');
// expect(mod2['__TYPE__']).toBe('BUILT_IN');
// });

test('should fail for unknown dependency', () => {
expect(() => {
Expand Down

0 comments on commit 21418aa

Please sign in to comment.