├── .gitignore
├── LICENSE
├── README.CRA.md
├── README.md
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── src
├── App.js
├── App.test.js
├── assets
│ └── locales
│ │ ├── en.js
│ │ └── index.js
├── components
│ ├── LoadingIndicator.jsx
│ ├── StoreProvider.jsx
│ ├── ThemeProvider.jsx
│ ├── UserRepositories
│ │ ├── UserRepositoriesList.jsx
│ │ └── UserRepositoriesListItem.jsx
│ ├── UserSelectionForm.container.jsx
│ └── UserSelectionForm.jsx
├── helpers
│ └── localization.js
├── index.js
├── logo.svg
├── pages
│ ├── Pages.container.jsx
│ ├── Pages.jsx
│ ├── PublicRepositoriesList.container.jsx
│ ├── PublicRepositoriesList.jsx
│ └── UserSelection.jsx
├── serviceWorker.js
├── services
│ └── github.js
├── store
│ ├── index.js
│ ├── repositories
│ │ ├── actionTypes.js
│ │ ├── actions.js
│ │ ├── reducer.js
│ │ └── selectors.js
│ └── user
│ │ ├── actionTypes.js
│ │ ├── actions.js
│ │ ├── reducer.js
│ │ └── selectors.js
└── test
│ ├── fixtures
│ └── github.js
│ ├── helpers
│ └── initTestLocalization.js
│ └── viewGitHubRepositoriesByUsername.spec.js
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (https://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # TypeScript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | # next.js build output
61 | .next
62 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
63 |
64 | # dependencies
65 | /node_modules
66 | /.pnp
67 | .pnp.js
68 |
69 | # testing
70 | /coverage
71 |
72 | # production
73 | /build
74 |
75 | # misc
76 | .DS_Store
77 | .env.local
78 | .env.development.local
79 | .env.test.local
80 | .env.production.local
81 |
82 | npm-debug.log*
83 | yarn-debug.log*
84 | yarn-error.log*
85 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Anton Rublev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.CRA.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `npm run build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-app-integration-tests-sample
2 | Sample integration tests implementation for a common react app structure
3 |
4 | [Read more about the the project and reasoning here.](https://www.toptal.com/blog/ADD_ARTICLE_LINK_HERE_WHEN_PUBLISHED)
5 |
6 | ## App implementation details
7 |
8 | Goal of the app implementation is follow a common react app structure and patterns while keeping it simple and small for ease of reading and understanding.
9 |
10 | The app implements a simple use case:
11 | 1. User enters a GitHub username
12 | 2. App displays a list of public repositories associated with the entered username
13 |
14 | The app includes:
15 |
16 | - API requests ([axios](https://github.com/axios/axios))
17 | - Internationalization support ([react-intl-universal](https://github.com/alibaba/react-intl-universal))
18 | - Global state management ([redux](https://github.com/reduxjs/redux) + [redux-thunk](https://github.com/reduxjs/redux-thunk))
19 | - CSS in JS solution ([@material-ui/styles](https://material-ui.com/styles/basics/))
20 | - SPA routing ([react-router-dom](https://github.com/ReactTraining/react-router/tree/master/packages/react-router-dom))
21 |
22 | The project was bootstrapped with [Create React App](./README.CRA.md).
23 |
24 | ## Integration tests
25 |
26 | Integration tests are written from User perspective and ignore as much of implementation details as possible.
27 | Instead, tests assert that user can interact with the DOM to fulfill a certain scenario.
28 |
29 | Integration tests are written using:
30 |
31 | - [jest](https://github.com/facebook/jest): JavaScript testing framework
32 | - [react-testing-library](https://github.com/testing-library/react-testing-library): Simple and complete React DOM testing utilities that encourage good testing practices.
33 | - [jest-dom](https://github.com/testing-library/jest-dom): Custom jest matchers to test the state of the DOM.
34 | - [nock](https://github.com/nock/nock): HTTP server mocking and expectations library.
35 |
36 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app-integration-tests-sample",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@material-ui/core": "^4.1.3",
7 | "@material-ui/styles": "^4.1.2",
8 | "axios": "^0.19.0",
9 | "mdi-material-ui": "^6.1.0",
10 | "react": "^16.8.6",
11 | "react-dom": "^16.8.6",
12 | "react-intl-universal": "^2.0.4",
13 | "react-redux": "^7.1.0",
14 | "react-router-dom": "^5.0.1",
15 | "react-scripts": "3.0.1",
16 | "redux": "^4.0.1",
17 | "redux-thunk": "^2.3.0"
18 | },
19 | "scripts": {
20 | "start": "react-scripts start",
21 | "build": "react-scripts build",
22 | "test": "react-scripts test",
23 | "eject": "react-scripts eject"
24 | },
25 | "eslintConfig": {
26 | "extends": "react-app"
27 | },
28 | "browserslist": {
29 | "production": [
30 | ">0.2%",
31 | "not dead",
32 | "not op_mini all"
33 | ],
34 | "development": [
35 | "last 1 chrome version",
36 | "last 1 firefox version",
37 | "last 1 safari version"
38 | ]
39 | },
40 | "devDependencies": {
41 | "@testing-library/react": "^8.0.4",
42 | "@testing-library/user-event": "^4.1.0",
43 | "jest-dom": "^3.5.0",
44 | "nock": "^10.0.6"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AntonRublev360/react-app-integration-tests-sample/8a6f12f04b86e79b583f13155613501d092e16c4/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |