2.3 KiB
JavaScript Functional Tests
Our JavaScript client functional tests are written using Jasmine and run in Karma.
Running tests from the command line
Easy Mode
- Start in the root of the repository
./build /t:Restore(Windows) /./build.sh /t:Restore(macOS/Linux)cd clients/ts/FunctionalTestsnpm test
Iterating
The npm test command will take a while, because it will build the clients\ts\signalr, clients\ts\signalr-protocol-msgpack and clients\ts\FunctionalTests folders as well as dotnet build the clients\ts\FunctionalTests folder (to build the server-side components). If you are making changes, it's nice to be able to build only the things you need to build. To skip all the optional build steps, you can run npm run test:inner in clients\ts\FunctionalTests. This will skip building clients\ts\signalr and clients\signalr-protocol-msgpack (it will still build the clients\ts\FunctionalTests folder). If you make changes to those libraries, you have to manually build those directories.
Running tests from the browser
- Start in the root of the repository
./build /t:Restore(Windows) /./build.sh /t:Restore(macOS/Linux)cd clients/tsnpm run build(Builds thesignalrandsignalr-protocol-msgpacklibraries)cd FunctionalTestsnpm run build(Builds theFunctionalTestsand copies in the necessary JavaScript)dotnet run
Copy-paste the URL that appears into the browser and the tests will run from the browser. They are easier to debug in the browser and you can use any browser you'd like.
Running tests on SauceLabs
Prerequisite: You need a SauceLabs account. Running tests this way will consume test minutes from your account so be careful!
You must set the SAUCE_USERNAME environment variable to your SauceLabs username and the SAUCE_ACCESS_KEY environment variable to your SauceLabs access key.
NOTE: Running this will open a secure virtual network tunnel from your local machine to SauceLabs using the Sauce Connect Proxy.
- Start in the root of the repository
./build /t:Restore(Windows) /./build.sh /t:Restore(macOS/Linux)cd clients/ts/FunctionalTestsnpm run sauce