Merge branch 'fix/postman-translations' of lohxt1:lohxt1/bruno into fix/handle-script-errors

This commit is contained in:
lohxt1 2025-01-16 15:36:56 +05:30
commit 0d595811a6
4 changed files with 37 additions and 7 deletions

View File

@ -34,7 +34,8 @@ import {
resetRunResults,
responseReceived,
updateLastAction,
setCollectionSecurityConfig
setCollectionSecurityConfig,
responseCleared
} from './index';
import { each } from 'lodash';
@ -235,6 +236,15 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
collectionCopy.globalEnvironmentVariables = globalEnvironmentVariables;
const environment = findEnvironmentInCollection(collectionCopy, collectionCopy.activeEnvironmentUid);
dispatch(
responseCleared({
itemUid: item.uid,
collectionUid: collectionUid,
response: null
})
);
sendNetworkRequest(itemCopy, collectionCopy, environment, collectionCopy.runtimeVariables)
.then((response) => {
return dispatch(

View File

@ -277,6 +277,8 @@ export const collectionsSlice = createSlice({
const item = findItemInCollection(collection, action.payload.itemUid);
if (item) {
item.response = null;
item.assertionResults = null;
item.testResults = null;
}
}
},

View File

@ -170,10 +170,19 @@ class TestRuntime {
}
if (this.runtime === 'quickjs') {
await executeQuickJsVmAsync({
script: testsFile,
context: context
});
try {
await executeQuickJsVmAsync({
script: testsFile,
context: context
});
}
catch(error) {
__brunoTestResults.addResult({
description: 'Invalid test script',
status: 'fail',
error: error?.message || 'An unexpected error occurred.'
});
}
} else {
// default runtime is vm2
const vm = new NodeVM({
@ -212,7 +221,17 @@ class TestRuntime {
}
});
const asyncVM = vm.run(`module.exports = async () => { ${testsFile}}`, path.join(collectionPath, 'vm.js'));
await asyncVM();
try {
await asyncVM();
}
catch(error) {
__brunoTestResults.addResult({
description: 'Invalid test script',
status: 'fail',
error: error.message || 'An unexpected error occurred.'
]
});
}
}
return {

View File

@ -3,7 +3,6 @@ const Test = (__brunoTestResults, chai) => async (description, callback) => {
await callback();
__brunoTestResults.addResult({ description, status: 'pass' });
} catch (error) {
console.log(chai.AssertionError);
if (error instanceof chai.AssertionError) {
const { message, actual, expected } = error;
__brunoTestResults.addResult({