Front-end web application build using ReactJS and Bootstrap.
- Docker
- Node version 7 or higher.
- Yarn.
- Install Docker
- Navigate to webapp folder.
- Build Website Container.
docker build . -t website
- Run Website Container on port 8080.
docker run -p 8080:80 website
yarn
- Run website.
yarn start
- Run Test
yarn test
Host: localhost
Port: 5432
Database: docker
User: docker Password: docker
- src
- images
- pages
- components
- services
Add a new folder for each component/page. Name the folder according to the item/feature you are building. Do not include the item type in the name. Example: Home
not HomePage
.
In each item folder, create a [item].js
, [item].css
and __tests__/[item].test.js
. Also create a components
folder where you will be break up parts of a page into re-usable components. A page should just be a collection of components, with each component (as far as possible) handling its own logic.
When wanting to call a service, create a folder in the services
folder with the name of the service and [service].js
that handles the service calls.
We are using Jest + Enzyme as a testing framework. Read this article, which explains how to use jest and enzyme. Note we are not doing snapshot testing - simply testing rendering, props and events.
Example
import React from 'react';
import {shallow} from 'enzyme';
import Home from '../Home.js';
test('Check if Home component renders.', () => {
// Render Home main component.
const wrapper = shallow(<Home />);
expect(wrapper.length).toEqual(1);
});
We use Bootstrap 4 as a CSS framework.