mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-15 09:19:28 +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,
|
resetRunResults,
|
||||||
responseReceived,
|
responseReceived,
|
||||||
updateLastAction,
|
updateLastAction,
|
||||||
setCollectionSecurityConfig
|
setCollectionSecurityConfig,
|
||||||
|
responseCleared
|
||||||
} from './index';
|
} from './index';
|
||||||
|
|
||||||
import { each } from 'lodash';
|
import { each } from 'lodash';
|
||||||
@ -235,6 +236,15 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
|
|||||||
collectionCopy.globalEnvironmentVariables = globalEnvironmentVariables;
|
collectionCopy.globalEnvironmentVariables = globalEnvironmentVariables;
|
||||||
|
|
||||||
const environment = findEnvironmentInCollection(collectionCopy, collectionCopy.activeEnvironmentUid);
|
const environment = findEnvironmentInCollection(collectionCopy, collectionCopy.activeEnvironmentUid);
|
||||||
|
|
||||||
|
dispatch(
|
||||||
|
responseCleared({
|
||||||
|
itemUid: item.uid,
|
||||||
|
collectionUid: collectionUid,
|
||||||
|
response: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
sendNetworkRequest(itemCopy, collectionCopy, environment, collectionCopy.runtimeVariables)
|
sendNetworkRequest(itemCopy, collectionCopy, environment, collectionCopy.runtimeVariables)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return dispatch(
|
return dispatch(
|
||||||
|
@ -277,6 +277,8 @@ export const collectionsSlice = createSlice({
|
|||||||
const item = findItemInCollection(collection, action.payload.itemUid);
|
const item = findItemInCollection(collection, action.payload.itemUid);
|
||||||
if (item) {
|
if (item) {
|
||||||
item.response = null;
|
item.response = null;
|
||||||
|
item.assertionResults = null;
|
||||||
|
item.testResults = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -170,10 +170,19 @@ class TestRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.runtime === 'quickjs') {
|
if (this.runtime === 'quickjs') {
|
||||||
|
try {
|
||||||
await executeQuickJsVmAsync({
|
await executeQuickJsVmAsync({
|
||||||
script: testsFile,
|
script: testsFile,
|
||||||
context: context
|
context: context
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch(error) {
|
||||||
|
__brunoTestResults.addResult({
|
||||||
|
description: 'Invalid test script',
|
||||||
|
status: 'fail',
|
||||||
|
error: error?.message || 'An unexpected error occurred.'
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// default runtime is vm2
|
// default runtime is vm2
|
||||||
const vm = new NodeVM({
|
const vm = new NodeVM({
|
||||||
@ -212,8 +221,18 @@ class TestRuntime {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const asyncVM = vm.run(`module.exports = async () => { ${testsFile}}`, path.join(collectionPath, 'vm.js'));
|
const asyncVM = vm.run(`module.exports = async () => { ${testsFile}}`, path.join(collectionPath, 'vm.js'));
|
||||||
|
try {
|
||||||
await asyncVM();
|
await asyncVM();
|
||||||
}
|
}
|
||||||
|
catch(error) {
|
||||||
|
__brunoTestResults.addResult({
|
||||||
|
description: 'Invalid test script',
|
||||||
|
status: 'fail',
|
||||||
|
error: error.message || 'An unexpected error occurred.'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
request,
|
request,
|
||||||
|
@ -3,7 +3,6 @@ const Test = (__brunoTestResults, chai) => async (description, callback) => {
|
|||||||
await callback();
|
await callback();
|
||||||
__brunoTestResults.addResult({ description, status: 'pass' });
|
__brunoTestResults.addResult({ description, status: 'pass' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(chai.AssertionError);
|
|
||||||
if (error instanceof chai.AssertionError) {
|
if (error instanceof chai.AssertionError) {
|
||||||
const { message, actual, expected } = error;
|
const { message, actual, expected } = error;
|
||||||
__brunoTestResults.addResult({
|
__brunoTestResults.addResult({
|
||||||
|
Loading…
Reference in New Issue
Block a user