Skip to content

SuichiM/starsWarsProject

Repository files navigation

The Stars Wars Challenge

This is a React & Typescrypt based project, that allow you interact with the SW-API

stack:

  • Coded on React 17
  • Uses hooks instead of Classes.
  • Uses Context API. (Avoiding Redux)
  • Fully typed using typescript.
  • Follows Airbnb code style

setting the project for dev

in all cases you must clone this repository as first step

## by https
git clone https://github.com/SuichiM/starsWarsProject.git

## or by ssh
git clone [email protected]:SuichiM/starsWarsProject.git

you have serveral ways to run the project, we strongly recommend run the project in a docker container using docker-compose.

running on your local machine

requirements node 12+

  1. install the dependecies
npm i
  1. run the dev server
npm run start

running on a docker container

  1. build the container
docker build  -t my_stars_wars_container .
  1. run the container
docker run -p 8080:8080 -v $PWD:/home/app -d my_stars_wars_container
  1. install the dependencies
docker exec <container_name> npm i
  1. run the dev server
docker exec <container_name> npm run start

running with docker-compose

having docker-compose simplifies the process to run the project in a container.

  1. build and run the service
docker-compose up -d
  1. install the dependecies
docker-compose exec web npm i
  1. run the dev server
docker-compose exec web npm run start

OTHER COMMANDS TO RUN

# compile the project for production
npm run build

# lint and fix the files follow the styleguide
npm run lint

#format the code
npm run format

testing with cypress

for test the aplication you can run the commands as follow. These commands will create a docker container that runs cypress.

for test the aplication you must have the dev server running.

first of all move to the e2e folder

cd e2e

running the tests on command line

docker run -it --rm \
 --network host \
  -e CYPRESS_baseUrl=http://localhost:8080 \
  -v $PWD:/e2e \
  -w /e2e \
  --entrypoint cypress \
  cypress/included:6.2.1 run --project .

opening the cypress UI for run the tests

run this command on a terminal

xhost +local:
 docker run -it --rm \
 --network host \
  -v ~/.Xauthority:/root/.Xauthority:ro \
  -e DISPLAY=unix${DISPLAY} \
  -e CYPRESS_baseUrl=http://localhost:8080 \
  -v $PWD:/e2e \
  -w /e2e \
  --entrypoint cypress \
  cypress/included:6.2.1 open --project .

feel free to send your PR for any improvement or bugfix

SuichiM