Skip to content

Commit b6b5825

Browse files
authored
Merge pull request #34 from MaxWeisen/genTests
Fixed Endpoint Testing
2 parents 87e4e7b + 3a960fc commit b6b5825

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/components/Modals/modalHooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function useGenerateScript(test, testType = null, puppeteerUrl = 'sample.
100100
{
101101
endPointGuide: endPointGuide,
102102
cd: `cd ${projectFilePath}`,
103-
install: 'npm i -D jest supertest',
103+
install: 'npm i -D jest supertest regenerator-runtime',
104104
}
105105
);
106106
case 'puppeteer':

src/context/useGenerateTest.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ function useGenerateTest(test, projectFilePath) {
514514
let filePath = ipcRenderer.sendSync('Universal.path', projectFilePath, serverFilePath);
515515
filePath = filePath.replace(/\\/g, '/');
516516
testFileCode = `const app = require('../${filePath}');
517-
const supertest = require('supertest')
517+
const supertest = require('supertest');
518+
const regeneratorRuntime = require('regenerator-runtime');
518519
const request = supertest(app)\n`;
519520
} else testFileCode = 'Please Select A Server!';
520521
if (dbFilePath) {
@@ -749,7 +750,7 @@ function useGenerateTest(test, projectFilePath) {
749750

750751
// // Endpoint Jest Test Code
751752
const addEndpoint = (statement) => {
752-
testFileCode += `\n test('${statement.testName}', async () => {\n const response = await request.${statement.method}('${statement.route}')`;
753+
testFileCode += `\n test('${statement.testName}', async () => {\n const response = await request.${statement.method}('${statement.route}');`;
753754
testFileCode += statement.postData
754755
? `.send( ${statement.postData.trim()})\n.set({'Content-Type': 'application/json',`
755756
: statement.headers.length
@@ -768,7 +769,7 @@ function useGenerateTest(test, projectFilePath) {
768769
.replace(/\(([^)]+)\)/, '')
769770
.split(' ')
770771
.join('');
771-
testFileCode += `expect(response.${expectedResponse.toLowerCase()})`;
772+
testFileCode += `\n expect(response.${expectedResponse.toLowerCase()})`;
772773
testFileCode += not ? `.not.${matcher}(${value});` : `.${matcher}(${value});`;
773774
});
774775
testFileCode += '});';

0 commit comments

Comments
 (0)