Skip to content

Commit e8ec11c

Browse files
authored
Merge pull request #51 from rachethecreator/travis
Travis
2 parents 2620295 + c95aa2a commit e8ec11c

File tree

3 files changed

+80
-54
lines changed

3 files changed

+80
-54
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: node_js
2+
node_js:
3+
- 'node'
4+
cache:
5+
directories:
6+
- node_modules
7+
script:
8+
- npm run build
9+
deplloy:
10+
skip_cleanup: true
11+
on: master

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
![](https://lh5.googleusercontent.com/5Gr2dZXHJdmIiASsPw9put-6mR20e4g1gOk-af4krREaJ7NqkZnqXLD5QgiotfNHYhGRh387HSqdhjRwxdwOvQzg9ChhfIrZz0FdxVu6gktBtG-sy1MX6Xq36Gmrzu_6G_K7LDQZ)
22

3-
Spearmint helps developers easily create functional React/Redux tests without writing any code. It dynamically converts user inputs into executable Jest test code by using DOM query selectors provided by @testing-library.
4-
5-
Spearmint is currently under development! We just finished our MVP and are looking for beta testers. Please open a new issue with details to report a bug. Adding support to mock API requests, context, and hooks are on the roadmap.
3+
Spearmint helps developers easily create functional React/Redux/Endpoint tests without writing any code. It dynamically converts user inputs into executable Jest test code by using DOM query selectors provided by @testing-library.
64

75
## How to use
86

9-
Download spearmint @ spearmintjs.com. Available for Mac OS and Windows. To run tests generated by spearmint install jest, @testing-library/jest-dom, @testing-library/react, and test-data-bot in your dev dependencies.
7+
Download spearmint @ spearmintjs.com. Available for Mac OS and Windows.
8+
9+
To run React tests generated by spearmint, install the following in your dev dependencies.
1010

1111
npm i -D jest @testing-library/jest-dom @testing-library/react test-data-bot
1212

13+
To run Redux tests generated by spearmint, install the following in your dev dependencies, in addition to your React test installations above.
14+
15+
npm i -D redux-mock-store redux-thunk fetch-mock
16+
17+
To run Hooks / Context tests generated by spearmint, install the following in your dev dependencies, in addition to your React test installations above.
18+
19+
npm i -D @testing-library/react-hooks
20+
21+
To run Endpoint tests generated by spearmint, install the following in your dev dependencies.
22+
23+
npm i -D jest supertest
24+
1325
## How it works
1426

15-
1. On the initial screen, enter the URL of your project and load your React/Redux application to start creating tests.
27+
1. On the initial screen, enter the URL of your project and load your application to start creating tests.
1628

1729
![](https://lh4.googleusercontent.com/CAFpoefRUUxgNosudQuc7gabSReFiI_puZ_WTjrzUSzB6pgOUdQ1babF2mxJql2lC8TQ-jjVLOgG5Qka8SUfF2fi-u2H9xSP7rZ_0Udpj-ISFPAY028UYKIUZcgOApnipVZwE7xh)
1830

19-
2. Utilize our auto-complete, drop-down options, and tooltips features to easily create arrangement, action, and assertion test statements for React, in addition to reducer, action creator, asynchronous action creator, and middleware test statements for Redux.
31+
2. Utilize our auto-complete, drop-down options, and tooltips features to easily create arrangement, action, and assertion test statements for React; reducer, action creator, asynchronous action creator, and middleware test statements for Redux; and hooks, context, and endpoint test statements.
2032

2133
![](https://lh5.googleusercontent.com/5VYUlGG5VDdZxdZEh5aokuilhKRp8B5QyVmxvtW_abLYCAzYN-s-el1oV5WMtGuTzbEO2I6l8Ys_yK2gC0fCi8ISHwjh4LlgezsrPWd7mDEtLbPqBYf1J4pgkGmfIV4yq4I_dpQg)
2234

@@ -29,12 +41,12 @@ Download spearmint @ spearmintjs.com. Available for Mac OS and Windows. To run t
2941
## Team
3042

3143
> Alex [@apark0720](https://github.com/apark0720)  · 
32-
> Johnny [@johnny-lim](https://github.com/johnny-lim)  · 
33-
> Julie [@julicious100](https://github.com/julicious100)  · 
34-
> Natlyn [@natlynp](https://github.com/natlynp)  · 
35-
> Karen [@karenpinilla](https://github.com/karenpinilla)  · 
3644
> Chloe [@HeyItsChloe](https://github.com/HeyItsChloe)  · 
3745
> Cornelius [@corneeltron](https://github.com/corneeltron)  · 
3846
> Dave [@davefranz](https://github.com/davefranz)  · 
47+
> Johnny [@johnny-lim](https://github.com/johnny-lim) <br />
48+
> Julie [@julicious100](https://github.com/julicious100) &nbsp;&middot;&nbsp;
49+
> Karen [@karenpinilla](https://github.com/karenpinilla) &nbsp;&middot;&nbsp;
3950
> Linda [@lcwish](https://github.com/lcwish) &nbsp;&middot;&nbsp;
51+
> Natlyn [@natlynp](https://github.com/natlynp) &nbsp;&middot;&nbsp;
4052
> Rachel [@rachethecreator](https://github.com/rachethecreator)

src/containers/NavBar/Modals/ExportFileModal.jsx

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,36 @@ const ExportFileModal = ({ isExportModalOpen, closeExportModal }) => {
262262
testFileCode += '\n';
263263
};
264264

265+
/* ------------------------------------------ ENDPOINT IMPORT + TEST STATEMENTS ------------------------------------------ */
266+
267+
// Endpoint Import Statements
268+
const addEndpointImportStatements = () => {
269+
endpointTestCase.endpointStatements.forEach(statement => {
270+
switch (statement.type) {
271+
case 'endpoint':
272+
return createPathToServer(statement);
273+
default:
274+
return statement;
275+
}
276+
});
277+
testFileCode += '\n';
278+
};
279+
280+
const addEndpointTestStatements = () => {
281+
testFileCode += `\n test('${endpointTestCase.endpointTestStatement}', async (done) => {`;
282+
endpointTestCase.endpointStatements.forEach(statement => {
283+
switch (statement.type) {
284+
case 'endpoint':
285+
return addEndpoint(statement);
286+
default:
287+
return statement;
288+
}
289+
});
290+
testFileCode += 'done();';
291+
testFileCode += '});';
292+
testFileCode += '\n';
293+
};
294+
265295
/* ------------------------------------------ FILEPATHS ------------------------------------------ */
266296

267297
// Actions Filepath
@@ -306,6 +336,17 @@ const ExportFileModal = ({ isExportModalOpen, closeExportModal }) => {
306336
testFileCode += `import { ${statement.providerComponent}, ${statement.consumerComponent}, ${statement.context} } from '../${filePath}';`;
307337
};
308338

339+
// Endpoint Filepath
340+
const createPathToServer = statement => {
341+
let filePath = path.relative(projectFilePath, statement.serverFilePath);
342+
filePath = filePath.replace(/\\/g, '/');
343+
testFileCode = `const app = require('../${filePath}');
344+
const supertest = require('supertest')
345+
const request = supertest(app)\n`;
346+
347+
testFileCode += '\n';
348+
};
349+
309350
/* ------------------------------------------ MOCK DATA + METHODS ------------------------------------------ */
310351

311352
const addMockData = () => {
@@ -338,6 +379,7 @@ const ExportFileModal = ({ isExportModalOpen, closeExportModal }) => {
338379
};
339380

340381
/* ------------------------------------------ TEST STATEMENTS ------------------------------------------ */
382+
341383
// Action Jest Test Code
342384
const addAction = action => {
343385
if (action.eventValue) {
@@ -491,53 +533,14 @@ const ExportFileModal = ({ isExportModalOpen, closeExportModal }) => {
491533
}
492534
};
493535

494-
/* --------------------------------ENDPOINT FUNCTIONS ------------------------------------------ */
495-
496-
const addEndpointImportStatements = () => {
497-
endpointTestCase.endpointStatements.forEach(statement => {
498-
switch (statement.type) {
499-
case 'endpoint':
500-
return createPathToServer(statement);
501-
default:
502-
return statement;
503-
}
504-
});
505-
testFileCode += '\n';
506-
};
507-
508-
const createPathToServer = statement => {
509-
let filePath = path.relative(projectFilePath, statement.serverFilePath);
510-
filePath = filePath.replace(/\\/g, '/');
511-
testFileCode = `const app = require('../${filePath}');
512-
const supertest = require('supertest')
513-
const request = supertest(app)\n`;
514-
515-
testFileCode += '\n';
516-
};
517-
518-
const addEndpointTestStatements = () => {
519-
testFileCode += `\n test('${endpointTestCase.endpointTestStatement}', async (done) => {`;
520-
endpointTestCase.endpointStatements.forEach(statement => {
521-
switch (statement.type) {
522-
case 'endpoint':
523-
return addEndpoint(statement);
524-
default:
525-
return statement;
526-
}
527-
});
528-
testFileCode += 'done();';
529-
testFileCode += '});';
530-
testFileCode += '\n';
531-
};
532-
536+
// Endpoint Jest Test Code
533537
const addEndpoint = statement => {
534-
testFileCode += `const response = await request.${statement.method}('${statement.route}')`;
535-
536-
testFileCode += '\n';
537-
538-
testFileCode += `expect(response.${statement.expectedResponse}).toBe(${statement.value});`;
538+
testFileCode += `const response = await request.${statement.method}('${statement.route}')
539+
expect(response.${statement.expectedResponse}).toBe(${statement.value});`;
539540
};
540541

542+
/* ------------------------------------------ EXPORT + DISPLAY FILE ------------------------------------------ */
543+
541544
const exportTestFile = async () => {
542545
if (!fs.existsSync(projectFilePath + '/__tests__')) {
543546
fs.mkdirSync(projectFilePath + '/__tests__');

0 commit comments

Comments
 (0)