This project satifies the requirements of the of the Slack Coding Exercise. Terminology used assumes a non-Windows operating system (Mac, specifically), but all intructions should loosely apply to any configuration.
I have used extensive commenting in the source files. I typically do not comment this much or check in code not being used, but wanted to show as much of my thought process and work as possible.
Cypress was the chosen framework for validating the creation of a new message in Slack, saving it, verifying its existence in the Saved items list, searching for all saved items, and verifying its existence in those search results.
In order to successfully run this test suite, the following conditions must be met:
- Project must be extracted or cloned locally, and user must be in project directory.
- Node.js must be installed. See How to install Node.js.
- Cypress must be installed. As this is a project dependency, attempting to run the suite will prompt you to install (no action necessary at this time). If this automated process fails,
npm install cypress
or the official installation guide can be used.
This test suite can be run from the command line or from the Cypress.app with a variety of options for each.
The following commands can be used to execute the suite:
npx cypress run
will run the default browser in headless modenpx cypress run --headed
will run the default browser in headed modenpx cypress run --browser chrome
will run the Chrome browser in headless mode
See the official cypress run
documentation for more information.
The npx cypress open
command will open the Cypress application as below:
Docker was selected as the container of choice as it is ubiquitous, and there is already a Cypress image available.
A variety of installation and runner scripts have been made available, but it is intended ./kitchen-sink.sh
be used as an all-in-one solution.
- Project must be extracted or cloned locally, and user must be in project directory.
A number of installation methods have been provided given the modular script setup used. Due to "resource" constraints (an eight day old daughter) only the Mac version is tested. If using Windows, Windows Subsystem for Linux must be installed and configured to run Ubuntu, and then the Linux installer and runner can theoretically be used.
Will install all prerequisites.
./scripts/install-mac.sh
will install on Mac./scripts/install-linux.sh
will install on Linux
./kitchen-sink -i
will detect and install for your given operating system (Mac or Linux)
Should installation fail, the following steps can be followed for manual installation:
- Install Node.js. See How to install Node.js.
- Install Node Modules by running
npm install
. - Install Docker and run it.
./scripts/runner.sh
supports all Cypress options such as --headed
and --browser
, amongst others, and will attempt to launch Docker (if not already running) on your operating system of choice (Mac or Linux).
./kitchen-sink -r
runs the above command, supports the same Cypress options, and also attempts to start Docker when necessary.
Results are output using Mochawesome, and stored in the mochawesome-report
directory.
This tool was chosen because it is built on Mocha, can therefore integrate easily with Cypress (also built on Mocha), and it produces both human-readable .html
reports and .json
files for further integrations.
These results can be opened with open mochawesome-report/mochawesome.html
or ./kitchen-sink -l
This script is the crux of this exercise. It is able to install prerequisites based on your detected operating system, run the test suite, and open the results in one fell swoop. Running the script with a -h
or --help
argument provides the following usage documentation:
usage: ./kitchen-sink.sh [-h|--help] [-i|--install] [-r|--run] [-l|--log] [*]
-h or --help prints this documentation and halts further execution
-i or --install install prerequisites
-r or --run run test suite in docker
-l or --log open html test report
* any remaining options to be passed to the cypress executable