diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index 75c6f2cb9..935ed6c91 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -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( diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js index d4ad48921..cc115282e 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js @@ -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; } } }, diff --git a/packages/bruno-js/src/runtime/test-runtime.js b/packages/bruno-js/src/runtime/test-runtime.js index 71db9d83e..39cc4395f 100644 --- a/packages/bruno-js/src/runtime/test-runtime.js +++ b/packages/bruno-js/src/runtime/test-runtime.js @@ -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 { diff --git a/packages/bruno-js/src/test.js b/packages/bruno-js/src/test.js index dd449e740..31ef985cf 100644 --- a/packages/bruno-js/src/test.js +++ b/packages/bruno-js/src/test.js @@ -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({