Skip to content

ProLoser/askdarcel-web

 
 

Repository files navigation

ShelterTech Web App Travis CI Status

Sauce Labs Browser Test Status

Sauce Test Status

Docker-based Development Environment (Recommended)

Requirements

Docker Community Edition (CE) >= 17.06 Docker Compose >= 1.18

Follow the Docker installation instructions for your OS.

Set up the project

This is not a full guide to Docker and Docker Compose, so please consult other guides to learn more about those tools.

The docker-compose.yml is configured to mount the git repo on your host filesystem into the Docker container so that any changes you make on your host machine will be synced into the container and vice versa.

Creating the .env file

The .env file is a de facto file format that allows you to specify environment variables that can be read by an application. It makes it easier to pass environment variables to an application without manually having to set them in the environment. It is supported by:

Create a file named .env with the credentials listed in this document.

Building and running the application

# Install node dependencies
$ docker-compose run --rm web npm install

# Build static assets bundle
$ docker-compose run --rm web npm run build

# Run dev server
$ docker-compose up

You should be able to view the web app in your browser at http://localhost:8080.

By default, this assumes that you have also set up askdarcel-api project using the Docker setup instructions and that the API server is running. If you want to target a different instance of askdarcel-api, you can modify the API_URL environment variable in docker-compose.yml.

Configuration (For both Dockerized or Local setup)

All config should be added in a file called config.yml. A sample config.example.yml is provided, you need to copy it to add your own

Algolia

Algolia is used as our search engine and in order for it to operate properly for everyone, we each need our own index.

  • in config.yml set your github username as the value for ALGOLIA_INDEX_PREFIX. This will point to the search index matching your local environment.

Non-Docker Development Environment

Installing Node.js and npm

We recommend using nvm (Node Version Manager) or Docker to ensure that the versions of Node.js and npm are the same across development, Travis CI, staging, and production environments.

After installing nvm, to install both Node.js and npm run from the top of the git repo:

$ nvm install  # Reads from .nvmrc

Installing npm dependencies

To install the dependencies, from the top directory run

npm install

To build the bundled script with webpack run

npm run build

And to run the dev server, run

npm run dev

End to end testing

Quick summary of what TestCafe is and how it works

It's a framework for running end-to-end tests (read: real browser tests) that injects your tests onto an existing web page. Architecturally, they spin up a lightweight proxy server that wraps your web page, and when you connect a browser to the proxy server, it serves the requested page with the test driver injected into it.

It's essentially an alternative to writing Selenium tests, and I've found it nice to use because it mimics many of the common HTML5 DOM APIs and because they've added a lot of reasonable default behavior that Selenium lacks, such as properly waiting for events to finish running and for elements to appear before running your assertions.

How to run

If you are not using Docker and all the services are bound to localhost, then you should just be able to run:

$ npm run testcafe -- --skip-js-errors chrome testcafe/*.js

Note: Make sure you have the dev server running (npm run dev) before you try running the above

If you are using Docker, then you'll need to run it somewhat like this:

$ docker-compose run --rm -p 1337:1337 -e BASE_URL=http://web:8080 web npm run testcafe -- --skip-js-errors remote --skip-js-errors --hostname localhost --ports 1337,1338 ./testcafe/

This will spin up a web server at http://localhost:1337/ and print out a URL to use. You should manually enter it into your browser to start the tests.

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs

Powered By Sauce Labs

About

The "Ask Darcel" web app.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 73.0%
  • CSS 25.6%
  • Other 1.4%