Closed Nizoryu closed 4 days ago
Hi @Nizoryu, access to files outside of the collection path is not allowed in Bruno. When doing so you'll get an error message saying 'Error: Access to files outside of the collectionPath is not allowed'. I'm not sure why you are getting a 'Cannot find module' message. Can you check again and get back? Thanks! Also from the file structure you've shown, I assume 'demo' as your collection.
Related to #1397 and #795
Could you share your use case? Are you looking to share a common script file across multiple collections?
Could you share your use case? Are you looking to share a common script file across multiple collections?
@Nizoryu , it is possible to do that, with two considerations
1) You have to declare the external path (take a look into #795) 2) It only works in pre-request. There is an unmmerged PR that aims to make it work in post-response: #1397
@Nizoryu , it is possible to do that, with two considerations
- You have to declare the external path (take a look into [feature] allow multiple script context roots #795)
- It only works in pre-request. There is an unmmerged PR that aims to make it work in post-response: feat(scripting): allow multiple script context roots in response scripts #1397
Thank you for you help, the external path is perfect for my use case.
I have checked the following:
Describe the bug
I have no problem running my script from the root folder of the collection.
When I move the file to the parent folder like this:
i have this issue: Error invoking remote method 'send-http-request': VMError: Cannot find module '../script.js'
.bru file to reproduce the bug
meta { name: get demo type: http seq: 2 }
get { url: http://localhost:3000 body: none auth: none }
script:pre-request { const script = require("../script.js"); // const moment = require('moment');
console.log(bru.getVar('today')); }
Screenshots/Live demo link