Skip to content

Commit 1b074fe

Browse files
committed
merging with develop to solve failing test issue
1 parent f7dd17a commit 1b074fe

File tree

242 files changed

+56081
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+56081
-0
lines changed

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
],
6+
"plugins": [
7+
"@babel/plugin-proposal-class-properties",
8+
["@babel/transform-runtime"]
9+
]
10+
}

.coveralls.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repo_token: 2Mbru2yeJDWONxQvtfO5SWATvDi2VuZL9

.github/pull_request_template.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Description
2+
3+
This set up a project from scratch without using npx create-react-app
4+
5+
6+
## Type of change
7+
8+
Please check the options that are relevant.
9+
10+
- [ ] Bug fix (non-breaking change which fixes an issue)
11+
- [X] New feature (non-breaking change which adds functionality)
12+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
13+
- [ ] This change requires a documentation update
14+
15+
# How should this be manually tested or reproduced?
16+
17+
- Clone this repo
18+
- Run the command `npm i`
19+
- Run the command `npm start`
20+
21+
# Checklist:
22+
23+
- [X] My code follows the style guidelines of this project
24+
- [ ] I have performed a self-review of my own code
25+
- [ ] I have commented my code, particularly in hard-to-understand areas
26+
- [ ] I have made corresponding changes to the documentation
27+
- [ ] My changes generate no new warnings
28+
- [ ] I have added tests that prove my fix is effective or that my feature works
29+
- [ ] New and existing unit tests pass locally with my changes
30+
- [ ] Any dependent changes have been merged and published in downstream modules
31+
32+
# Screenshots (if applicable)

.github/workflows/main.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ develop ]
9+
pull_request:
10+
branches: [ develop ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [10.x, 12.x, 14.x, 15.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- run: npm ci
29+
- run: npm run build --if-present
30+
- run: npm test
31+
- run: npm run coverage

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.DS_STORE
2+
node_modules
3+
scripts/flow/*/.flowconfig
4+
.flowconfig
5+
*~
6+
*.pyc
7+
.grunt
8+
_SpecRunner.html
9+
__benchmarks__
10+
build/
11+
remote-repo/
12+
coverage/
13+
.module-cache
14+
fixtures/dom/public/react-dom.js
15+
fixtures/dom/public/react.js
16+
test/the-files-to-test.generated.js
17+
*.log*
18+
chrome-user-data
19+
*.sublime-project
20+
*.sublime-workspace
21+
.idea
22+
*.iml
23+
.vscode
24+
*.swp
25+
*.swo
26+
.env
27+
packages/react-devtools-core/dist
28+
packages/react-devtools-extensions/chrome/build
29+
packages/react-devtools-extensions/chrome/*.crx
30+
packages/react-devtools-extensions/chrome/*.pem
31+
packages/react-devtools-extensions/firefox/build
32+
packages/react-devtools-extensions/firefox/*.xpi
33+
packages/react-devtools-extensions/firefox/*.pem
34+
packages/react-devtools-extensions/shared/build
35+
packages/react-devtools-extensions/.tempUserDataDir
36+
packages/react-devtools-inline/dist
37+
packages/react-devtools-shell/dist
38+
packages/react-devtools-scheduling-profiler/dist

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web:npm start

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# c4-barefoot-frontend
2+
3+
![CI](https://github.com/atlp-rwanda/c4-barefoot-frontend/workflows/CI/badge.svg?)
4+
[![Maintainability](https://api.codeclimate.com/v1/badges/0e0e17e256bddb871c2b/maintainability)](https://codeclimate.com/github/atlp-rwanda/c4-barefoot-frontend/maintainability)
5+
[![Coverage Status](https://coveralls.io/repos/github/atlp-rwanda/c4-barefoot-frontend/badge.svg?branch=develop)](https://coveralls.io/github/atlp-rwanda/c4-barefoot-frontend?branch=develop)
6+
7+
## Setting react project from scratch
8+
9+
- First of all you need to clone project reposotory by running
10+
`git clone git clone https://github.com/atlp-rwanda/c4-barefoot-frontend.git`
11+
12+
## Initializing node module packages
13+
14+
- run `npm init --yes` here package.json will be created imadiately
15+
16+
## Installation dependencies
17+
18+
Here we need to install all packgages that will be used to set up our project
19+
20+
- `npm install react`
21+
- `npm i react-dom`
22+
- `npm i react-roouter-dom`
23+
24+
## Transipiling babel
25+
26+
We need compile our javascript file from ECMA2015 (ES6) to ES5
27+
28+
- `@babel/core`
29+
- `@babel/preset-env`
30+
- `@babel/preset-react`
31+
- `babel-loader`
32+
- `babel/core`
33+
34+
## Installing plugins that will allow react to unstander html files
35+
36+
- `npm i html-webpack-plugin`
37+
- `npm i htm-loader`
38+
39+
## In our project we need to style the pages we need to install this dependencies
40+
41+
- `npm i css-loader`
42+
- `npm i style-loader`
43+
44+
After that we will need to run our project in devlopment
45+
we have to make sure that webpack dependencies are installed like:
46+
47+
- `npm i webpack-cli` Note: here you have to pay more attation on version of webpack-cli I am using version: `3.3.12` other version is not working
48+
- `npm i webpack`
49+
- `npm i webpack-dev-server` This will helps us to run server automatically after save when you change any file content
50+
51+
## After that we need to tell webpack what to do
52+
53+
```const webpack = require('webpack');
54+
const path = require('path');
55+
const HtmlWebpackPlugin = require('html-webpack-plugin')
56+
process.env.NODE_ENV = 'development';
57+
58+
module.exports = {
59+
mode: 'development',
60+
devtool: 'cheap-module-source-map',
61+
entry: './src/index.js',
62+
output: {
63+
path: path.resolve(__dirname, "build"),
64+
publicPath: '/',
65+
filename: 'bundle.js'
66+
},
67+
devServer: {
68+
stats:'minimal',
69+
overlay: true,
70+
historyApiFallback: true,
71+
disableHostCheck: true,
72+
headers: { "Access-Control-Allow-Origin": "*"},
73+
https: false
74+
},
75+
76+
plugins: [
77+
new HtmlWebpackPlugin({
78+
template: "public/index.html"
79+
})
80+
],
81+
module : {
82+
rules: [
83+
{
84+
test: /\.(js|jsx)$/,
85+
exclude: /node_modules/,
86+
use: ["babel-loader"]
87+
},
88+
{
89+
test: /(\.css)$/,
90+
use: ["style-loader", "css-loader"]
91+
},
92+
{
93+
test: /\.html$/,
94+
use: [
95+
{
96+
loader: "html-loader"
97+
}
98+
]
99+
}
100+
]
101+
}
102+
};
103+
```
104+
105+
### Here we go now we can start our project by running `npm start`
106+
107+
you will get error that says `no start script available` now you can guess what do right now
108+
109+
let jump into package.json and configure `start script`
110+
111+
```"scripts": {
112+
"start": "webpack-dev-server --config webpack.config.js --port 3000 --open"
113+
}
114+
```
115+
116+
so far you can run `npm start`

__mocks__/fileMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'test-file-stub';

__mocks__/styleMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports ={};

__tests__/App.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import App from '../src/App';
3+
import history from '../src/history';
4+
import {BrowserRouter as Router} from 'react-router-dom'
5+
import Routers from '../src/routes/Routers';
6+
import { shallow } from 'enzyme';
7+
import toJson from 'enzyme-to-json';
8+
9+
describe('<App />', () =>{
10+
11+
it('matches snapshot', () => {
12+
const props = {
13+
history : jest.fn()
14+
}
15+
const wrapper = shallow(<App {...props} /> );
16+
let apptest = (<Router history={history}><Routers/></Router>);
17+
expect(toJson(wrapper)).toMatchSnapshot();
18+
});
19+
20+
})

0 commit comments

Comments
 (0)