Fork the project, clone your fork, configure the remotes and install the dependencies:
First, you'll need to Fork the project, clone your fork and configure the remote.
# Install the dependencies
npm install
# Navigate to the examples folder to set up the environment for working on the examples
cd examples
npm install
cd ..
This codebase is formatted using prettier.
- To check that the code is correctly formatted, run
npm run prettier:check
. - To automatically reformat the code with prettier, run
npm run prettier:apply
.
This codebase is written in TypeScript.
- To type-check the source tree, run
npm run type:check
.
To ensure consistency and quality, we enforce 100% test coverage, both for the jest-websocket-mock
source code and for the examples.
- To run the tests ,run
npm test -- --coverage
. - To run the examples tests, run
SKIP_PREFLIGHT_CHECK=true npm test -- --coverage
in theexamples
folder. TheSKIP_PREFLIGHT_CHECK=true
environment variable is needed because Create React App detects a different jest version in the root folder (even if it doesn't use it).
To ensure that a new library build stays backwards compatible, it is useful to run the tests for the example app using a local library build. To do so:
# build the library
npm run build
# generate a local library package
npm pack
# navigate to the examples folder
cd examples
# install the local library package
npm install ../jest-websocket-mock-*
# run the examples test suite
SKIP_PREFLIGHT_CHECK=true npm test -- --coverage
cd ..