- Fork it
- When pulling to local, make sure to also pull the
ably-common
repo (git submodule init && git submodule update
) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Ensure you have added suitable tests and the test suite is passing(
npm test
) - Ensure the type definitions have been updated if the public API has changed
- Push the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Make sure the tests are passing in CI for the branch you're building
- Create a new branch for the release, for example
release/1.2.3
- Update the CHANGELOG.md with any customer-affecting changes since the last release and add this to the git index
- Run
npm version <VERSION_NUMBER> --no-git-tag-version
with the new version and add the changes to the git index - Update the version number to the new version in
src/platform/react-hooks/src/AblyReactHooks.ts
- Create a PR for the release branch
- Once the release PR is landed to the
main
branch, checkout themain
branch locally (remember to pull the remote changes) and runnpm run build
- Run
git tag <VERSION_NUMBER>
with the new version and push the tag to GitHub withgit push <REMOTE> <VERSION_NUMBER>
(usuallygit push origin <VERSION_NUMBER>
) - Run
npm publish .
(should require OTP) - publishes to NPM - Run the GitHub action "Publish to CDN" with the new tag name
- Visit https://github.com/ably/ably-js/tags and create a GitHub release based on the new tag (for release notes, you generally can just copy the notes you added to the CHANGELOG)
- Update the Ably Changelog (via headwayapp) with these changes (again, you can just copy the notes you added to the CHANGELOG)
To build the library, simply run npm run build
. Building the library currently requires NodeJS >= v16.
Since webpack builds are slow, commands are also available to only build the output for specific platforms (eg npm run build:node
), see package.json for the full list of available commands
To run the Mocha tests, simply run the following command:
npm test
Run the Mocha test suite
npm run test:node
You can pass any Mocha CLI arguments and flags to the test:node script after the --
separator, for example running one test file:
npm run test:node -- test/realtime/auth.test.js
Or run just one test
npm run test:node -- --grep=test_name_here
Or run test skipping the build
npm run test:node:skip-build -- test/rest/status.test.js --grep=test_name_here
Run the following command to launch tests with the debugger enabled. The tests will block until you attach a debugger.
node --inspect-brk=9229 node_modules/.bin/mocha
Alternatively you can also run the tests for single file
node --inspect-brk=9229 node_modules/.bin/mocha test/realtime/auth.test.js
The included vscode launch config allows you to launch and attach the debugger in one step, simply open the test file you want to run and start debugging. Note that breakpoint setting for realtime code will be within the browser/static directory, not the raw source files, and breakpoints in files under test should work directly.
Run the following command to start a local Mocha test runner web server
npm run test:webserver
Open your browser to http://localhost:3000. If you are using a remote browser, refer to https://docs.saucelabs.com/reference/sauce-connect/ for instructions on setting up a local tunnel to your Mocha runner web server.
Run the following command to fix linting/formatting issues
npm run format
All tests are run against the sandbox environment by default. However, the following environment variables can be set before running the Karma server to change the environment the tests are run against.
ABLY_ENV
- defaults to sandbox, however this can be set to another known environment such as 'staging'ABLY_REALTIME_HOST
- explicitly tell the client library to use an alternate host for real-time websocket communication.ABLY_REST_HOST
- explicitly tell the client library to use an alternate host for REST communication.ABLY_PORT
- non-TLS port to use for the tests, defaults to 80ABLY_TLS_PORT
- TLS port to use for the tests, defaults to 443ABLY_USE_TLS
- true or false to enable/disable use of TLS respectivelyABLY_LOG_LEVEL
- Log level for the client libraries, defaults to 2, 4 isMICRO
When using the test webserver npm run test:webserver
the following test variables can be configured by appending them as params in the URL such as http://localhost:3000/mocha.html?log_level=4
.
env
- defaults to sandbox, however this can be set to another known environment such as 'staging'realtime_host
- explicitly tell the client library to use an alternate host for real-time websocket communication.host
- explicitly tell the client library to use an alternate host for REST communication.port
- non-TLS port to use for the tests, defaults to 80tls_port
- TLS port to use for the tests, defaults to 443tls
- true or false to enable/disable use of TLS respectivelylog_level
- Log level for the client libraries, defaults to 2, 4 isMICRO
The react sample application is configured to execute using Vite - which will load a sample web app that acts as a simple test harness for the hooks.
You can run the dev server from the terminal using:
npm run start:react
You'll need to provide an API key for the sample to work (or you'll just get a white page and some errors in the console). To do this, create the file ./src/platform/react-hooks/sample-app/.env
and add the following line:
VITE_ABLY_API_KEY=<your-api-key>
This API key will be loaded by the vite dev server at build time.
You can run the unit tests by running npm run test:react
in the terminal.