This directory contains the client side codebase for WComponents.
You will need either Java + Maven and/or Node + Yarn or NPM. The examples below use yarn but you can substitute with npm.
By default tests require Firefox browser to be installed on your system.
# First time only run yarn install
yarn install
# thenceforth
yarn run build
mvn compile
Custom build options are configured in the package.json under the section "com_github_bordertech"
.
To override these without modifying a file tracked by source control:
- Create a file in this directory with the format {username}.json, for example on Mac
vi $USER.json
- Make sure you add this to your global gitignore
- Add
com_github_bordertech
properties you want to override, for example your file contents may look like this:
{
"testMinOrMax": "max",
"internOverrides": {
"tunnelOptions": {
"baseUrl": "http://nexus.example.com/repository/my_raw/selenium/",
"drivers": [{
"baseUrl": "http://nexus.example.com/repository/my_raw/selenium/driver/gecko/",
"name": "firefox"
}]
}
}
}
cd wcomponents-theme
# "mvn test" or the commands below
yarn install
yarn run test
We use Intern to run tests.
Tests can be configured using Build Options (see above). Test specific options include:
-
internOverrides
Here you can override anything the intern configuration file, this is often an easier alternative to using
INTERN_ARGS
. -
testMinOrMax
By default we test the minified code but for debugging you will want to use the unminified version: set
testMinOrMax
to"max"
Because we use Intern for testing, you can override much of the configuration such as what tests, which browser, etc using the INTERN_ARGS
environment variable.
Auto-detect local headless firefox or remote saucelabs:
# If SAUCE_USERNAME and SAUCE_ACCESS_KEY env variables are set it will tunnel to saucelabs.
yarn run test
OR
mvn test
Run the tests in a browser on your machine:
yarn run test:local
Create a test server which you can visit in your browser to run tests:
# Run this then visit http://localhost:9000/__intern/
yarn run test:serve
Test against a running selenium server.
yarn run test:grid
Client side development is facilitated by automatic code compilation. This will detect changes as you work and selectively rebuild automatically. To enable this:
# Watches for changes to source code and compiles automatically
yarn run watch
When code is rebuilt using automatic code completion (see above) it is possible to have this loaded into a running browser without a page reload.
For example, when developing against the WComponents Java Examples.
- Run Automatic Code Completion (as described above) - this automatically starts a hot reload server.
- Make the examples use your locally built theme.
- Ensure you are running in debug mode
- In your browser:
EITHER:
/*
This will set a cookie that tells the hot reload client to automatically connect when the page loads.
You only need to do this once every 800 days (or whatever you set it to).
*/
require("wc/dom/cookie").create("wchotmod", "true", 800);
OR:
// This will force the hot reload client to connect to the server you are running
require("wc/debug/hotReloadClient").getConnection(true);