wakanda-client
v3.1.6
Published
Wakanda Client allows you to easily interact with Wakanda Server on a JavaScript (browser or node) environment
Downloads
9
Readme
Wakanda Javascript Client
Minimalist, framework agnostic, JavaScript client to interact with Wakanda Server REST API that exposes a standard and easy to use JavaScript API.
Install
Install through npm
or bower
. There is only browser version on bower
, both node and browser ones on npm
.
npm install wakanda-client
#or
bower install wakanda-client
Documentation
Check out the documentation to learn how to use Wakanda-Client.
Development
Git clone this repository then install dependencies. Wakanda Client needs Node 4.0 or greater.
npm install
Run (on web browser)
Launch webpack build on watch mode, it will rebuild the client when sources are edited.
npm run webpack-watch
On another tab, launch a server that serve example application on app/
directory.
npm run serve:proxy
Then open your browser on http://localhost:1136/app/index.html
.
Build (dev)
npm run webpack-build
Bundles are built on ./dist/
directory.
You can require
wakanda-client.node.js
on a Node application, or directly insert
wakanda-client.js
on a <script>
tag (it's a UMD module) and use WakandaClient
object.
Integration tests
Integration testing is made with mocha and chai. It directly runs tests against built bundles. Tests are written in ES5 to avoid useless compilation. There are two modes : one which runs tests against node bundle, the other against the umd module on PhantomJS with karma.
There also are commands to launch test without rebuilding the bundles.
#Build and run integration test for karma
npm run test:karma:full
#Run test for karma
npm run test:karma:single
#Build and run integration test for node
npm run test:node:full
#Run test for node
npm run test:node:single
There is a prism-connect server running
to mock a real Wakanda Server. It has JSON
mocks stored on test/connect/mocks/rest
. These JSON can be generated by launching
npm run test-server:init
. It will launch prism-connect server and proxy all requests
to a real Wakanda Server, then store the results. This operation must be do each time
tests are modified or added.
You can launch the mocking server by typing npm run test-server:start
and stop
it with npm run test-server:stop
.
Integration tests need this server to be running to execute.
You can use the two following scripts to run both Karma and node unit test with
test server launching and stopping alone. Just be sure that port 3000
is free.
#Run test server, build bundles and launch karma and node integration tests
npm run test
#Same as previous one but without building bundles
npm run test-single
Karma automatically proxies requests on /rest
to test server. For node
test, WakandaClient
module is instancied with test server address on each
test file.
If port 3000
doesn't suit your needs, you can change it on test/connect/server.js
and on test/server.integration.json
.
As PhantomJS doesn't support CustomEvent
constructor, there is a polyfill on test
directory.
License
MIT