mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-08 14:02:09 +01:00
Merge branch 'fix/postman-translations' of lohxt1:lohxt1/bruno into fix/handle-script-errors
This commit is contained in:
commit
0d595811a6
@ -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(
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -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 {
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user