mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 17:03:47 +01:00
feat: updates
This commit is contained in:
parent
f43775e245
commit
23531ec7af
@ -28,7 +28,12 @@ const TestResults = ({ results, assertionResults }) => {
|
||||
<>
|
||||
<span className="test-failure">✘ {result.description}</span>
|
||||
<br />
|
||||
<span className="error-message pl-8">{result.error}</span>
|
||||
{
|
||||
Array.isArray(result?.error)?
|
||||
result?.error?.map(error=><><span className="error-message pl-8">{error}</span><br/></>)
|
||||
:
|
||||
<span className="error-message pl-8">{result.error}</span>
|
||||
}
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
|
@ -34,7 +34,8 @@ import {
|
||||
resetRunResults,
|
||||
responseReceived,
|
||||
updateLastAction,
|
||||
setCollectionSecurityConfig
|
||||
setCollectionSecurityConfig,
|
||||
responseCleared
|
||||
} from './index';
|
||||
|
||||
import { each } from 'lodash';
|
||||
@ -235,6 +236,16 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
|
||||
collectionCopy.globalEnvironmentVariables = globalEnvironmentVariables;
|
||||
|
||||
const environment = findEnvironmentInCollection(collectionCopy, collectionCopy.activeEnvironmentUid);
|
||||
|
||||
// clear the old response
|
||||
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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -7,8 +7,11 @@ const replacements = {
|
||||
'pm\\.collectionVariables\\.set\\(': 'bru.setVar(',
|
||||
'pm\\.setNextRequest\\(': 'bru.setNextRequest(',
|
||||
'pm\\.test\\(': 'test(',
|
||||
'pm\\.response\\.headers\\.get\\(': 'res.getHeader(',
|
||||
'pm.response.to.have\\.status\\(': 'expect(res.getStatus()).to.equal(',
|
||||
'pm\\.response\\.to\\.have\\.status\\(': 'expect(res.getStatus()).to.equal(',
|
||||
'pm\\.response\\.to\\.have\\.body\\(': 'expect(res.getBody()).to.equal(',
|
||||
'pm\\.response\\.to\\.have\\.header\\(': 'expect(res.getHeader()).to.equal(',
|
||||
'pm\\.response\\.json\\(': 'res.getBody(',
|
||||
'pm\\.expect\\(': 'expect(',
|
||||
'pm\\.environment\\.has\\(([^)]+)\\)': 'bru.getEnvVar($1) !== undefined && bru.getEnvVar($1) !== null',
|
||||
|
@ -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({
|
||||
@ -14,10 +13,17 @@ const Test = (__brunoTestResults, chai) => async (description, callback) => {
|
||||
expected
|
||||
});
|
||||
} else {
|
||||
const errorStackLines = error.stack.split("\n");
|
||||
const lineInfo = errorStackLines[1];
|
||||
const lineNumber = lineInfo?.split(':')?.at?.(-2);
|
||||
const columnNumber = lineInfo?.split(':')?.at?.(-1);
|
||||
__brunoTestResults.addResult({
|
||||
description,
|
||||
status: 'fail',
|
||||
error: error.message || 'An unexpected error occurred.'
|
||||
error: [
|
||||
`Error occurred at line ${lineNumber} and character ${columnNumber}`,
|
||||
`${error.message || 'An unexpected error occurred.'}`
|
||||
]
|
||||
});
|
||||
}
|
||||
console.log(error);
|
||||
|
Loading…
Reference in New Issue
Block a user