fix: fixed issue where unsaved changes where not being picked up while running tests (#125)

This commit is contained in:
Anoop M D 2023-03-29 12:43:47 +05:30
parent bdb3051c2b
commit d346970241
2 changed files with 25 additions and 20 deletions

View File

@ -179,17 +179,15 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
});
// run tests
const testFile = get(item, 'request.tests');
if(testFile && testFile.length) {
const testRuntime = new TestRuntime();
const result = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
const testRuntime = new TestRuntime();
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
mainWindow.webContents.send('main:test-results', {
results: result.results,
itemUid: item.uid,
collectionUid
});
}
mainWindow.webContents.send('main:test-results', {
results: testResults.results,
itemUid: item.uid,
collectionUid
});
deleteCancelToken(cancelTokenUid);
@ -407,17 +405,15 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
}
// run tests
const testFile = get(item, 'request.tests');
if(testFile && testFile.length) {
const testRuntime = new TestRuntime();
const result = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
const testFile = item.draft ? get(item.draft, 'request.tests') : get(item, 'request.tests');
const testRuntime = new TestRuntime();
const testResults = testRuntime.runTests(testFile, request, response, envVars, collectionVariables, collectionPath);
mainWindow.webContents.send('main:run-folder-event', {
type: 'test-results',
testResults: result.results,
...eventData
});
}
mainWindow.webContents.send('main:run-folder-event', {
type: 'test-results',
testResults: testResults.results,
...eventData
});
mainWindow.webContents.send('main:run-folder-event', {
type: 'response-received',

View File

@ -28,6 +28,15 @@ class TestRuntime {
const __brunoTestResults = new TestResults();
const test = Test(__brunoTestResults, chai);
if(!testsFile || !testsFile.length) {
return {
request,
envVariables,
collectionVariables,
results: __brunoTestResults.getResults()
};
}
const context = {
test,
bru,