Skip to content
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

Implement pm.require #976

Merged
merged 11 commits into from
Feb 28, 2024
Merged

Implement pm.require #976

merged 11 commits into from
Feb 28, 2024

Conversation

coditva
Copy link
Member

@coditva coditva commented Feb 5, 2024

Adds pm.require to the pm API.

When resolvedPackages option is passed to the sandbox in execute, the pm.require API can be used to import the packages from the resolvedPackages cache.

  • The package is executed in the same scope.
  • The package follows the commonJS type of declaring modules such that modules.export is exported from the package.
  • See test/unit/sandbox-libraries/pm-require.test.js for more cases.

Note: Commits e7d4ed5 and 42e7dcd can be removed once postman-collection and uniscope are bumped.

package.json Outdated Show resolved Hide resolved
package.json Outdated
@@ -92,7 +92,7 @@
"terser": "^5.24.0",
"tsd-jsdoc": "^2.5.0",
"tv4": "1.3.0",
"uniscope": "2.0.1",
"uniscope": "postmanlabs/uniscope#feat/three-way-diff",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coditva coditva force-pushed the feat/script-require-pre-fetch branch from 1e089e6 to eba9f5a Compare February 16, 2024 06:32
lib/postman-sandbox.js Outdated Show resolved Hide resolved
return cache[path].exports;
}

/* eslint-disable-next-line one-var */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codenirvana I don't see the use of this eslint rule. I want to use const because the value never changes, but I don't want to evaluate it if I can bail out early. What're your thoughts?

@coditva coditva force-pushed the feat/script-require-pre-fetch branch from eba9f5a to 198a140 Compare February 16, 2024 06:51
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 60.56%. Comparing base (903677b) to head (552088e).

Files Patch % Lines
lib/sandbox/pmapi.js 33.33% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #976      +/-   ##
===========================================
- Coverage    60.71%   60.56%   -0.15%     
===========================================
  Files           12       12              
  Lines          560      563       +3     
  Branches       136      136              
===========================================
+ Hits           340      341       +1     
- Misses         220      222       +2     
Flag Coverage Δ
unit 60.56% <50.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coditva coditva force-pushed the feat/script-require-pre-fetch branch from 198a140 to e7d4ed5 Compare February 16, 2024 07:25
package.json Outdated
@@ -43,7 +43,7 @@
},
"dependencies": {
"lodash": "4.17.21",
"postman-collection": "4.3.0",
"postman-collection": "aditya-baradwaj/postman-collection#feature/APITEST-766-Add-Packages-to-collection-schema",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coditva coditva force-pushed the feat/script-require-pre-fetch branch from d90738f to acb1ca5 Compare February 21, 2024 07:21
@coditva coditva marked this pull request as ready for review February 21, 2024 08:44
@coditva coditva force-pushed the feat/script-require-pre-fetch branch from 277f79d to 552088e Compare February 28, 2024 09:23
@codenirvana codenirvana merged commit b6ca17e into develop Feb 28, 2024
9 checks passed
@codenirvana codenirvana deleted the feat/script-require-pre-fetch branch February 28, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants