Amaze test-driven development
This is a set of tools that will allow for test-driven development using the following technologies:
- Mocha
- Chai
- selenium-webdriver
- Chrome and PhantomJS
It contains everything you need to write functional tests for remote URLs.
Installation
Install the testing suite into your project root directory with:
npm install amaze-tdd --save
Writing tests
Ensure the testing suite is required at the top of the test. We use ES2015. Instantiate a global variable for Browser.
var Amaze = require('amaze-tdd');
var Browser;
Instantiate the browser object in the suiteSetup
function. You should look at another test to see an example.
Browser = Amaze.Client.build();
Tests should be written asynchronously due to Selenium's asynchronous nature. We should return something or use an expectation/assertion which returns a promise. An example test has been included for reference. We have also created further documentation on writing tests to help you write good tests.
Running tests
Run tests with:
node node_modules/amaze-tdd
You may pass in additional flags, such as sanity-check
to include the demo test. This may help with sanity checks if you're getting a bunch of test failures:
node node_modules/amaze-tdd sanity-check
Additionally, you may use PhantomJS to headlessly test the interfaces. No browser plugin is required and no browsers will spawn, which may speed up tests. Add the phantomjs
option:
node node_modules/amaze-tdd phantomjs
Test files
Our process will run Mocha on any files in the specified path with the format *-spec.js
. This means that the following examples will work:
test-spec.js
overlay-name-spec.js
camelCase-spec.js
ALLCAPS-spec.js
some-folder/test-spec.js
some-folder/nested-folder/test-spec.js
Basically any file that ends with -spec.js
will be covered in testing.
Contributing
We want you! To help us make this great. See our wiki on contributing for more information.
Changelog
0.2.8
- Changed the way the script checks for local configuration files.
0.2.7
- Updated the demo spec test to be more of a sanity check
- Removed
dev
option; changed prod
to phantomjs
for PhantomJS tests - Will only include the demo spec as a sanity check if
sanity-check
option is present - Tests will use your projects
.amazerc
file rather than the one included in this package - Slight tweaks to this readme file, typo fixes, and added link to documentation
- Documentation updates; copying stuff over to the Wiki
- Moved from Google ESlint rules to a custom set based on standard rules
0.2.6
- Removing the necessity to use a global install and removing the
bin
for the command - Instead, relying on the package.json
script
so we need only a single install of the files - Added support for an
.amazerc
configuration file for individual project settings - Removed Firefox (geckodriver) and IE (iedriver) from global object
- Using Chrome as default and PhantomJS for
phantomjs
option - Refactored some files to use ES2015, more on the way
- Included an ESlint config file and devDependencies
- Increased global timeout to 30s allowing removal of individual overrides
0.2.5
- Tweaking the global object
0.1.1
- Moved the demo test Browser instance into a suiteSetup to fix the empty browser that spawns during tests
- Fixed typo of this section heading :-)
0.1.0
- Removed unused Chai.should() library
- Added documentation
- Various cleanup and consolidations
0.0.15
- Added a jQuery wrapper to make working with Selenium easier
0.0.14
- Making Chrome plugin path work regardless of project
- Moving browser builder to individual tests. This is necessary so the browser can re-instantiate itself between tests.
0.0.13
0.0.12
- Directory structure updates; needed an index.js for easier module loading
0.0.11
- Removed selenium/mocha wrapper to reduce dependencies
- Moved to a promise-based test setup
- Switched from BDD to TDD for clarity
- Preferring local install to global; was previously global
- Added changelog :-)
0.0.1 - 0.0.10
- Regretting not starting a changelog sooner
- Basically gets stuff setup and working through bugs