-
Notifications
You must be signed in to change notification settings - Fork 1
Testing
Testing is performed on multiple browsers via Mocha/Chai and Karma
To test the project download via GIT:
git pull https://github.com/Tokimon/vanillajs-browser-helpers.git
Run the install:
npm install
Build the polyfills needed:
npm run polyfills
Run the test:
npm test
Since there are a lot of files to test on several different browser platforms the tests can be customized via CLI parameters:
-
--test/-t
: The name of the file(s) you want to execute (eg.-t append
=> 'tests/append.spec.js') -
--browser/-b
: The name of the browser (in lowercase) you want to execute tests in (eg.-b firefox
) - currenty limited to:chrome
,firefox
, (ie)edge
,ie
(ie 11),ie10
,ie9
-
--root/-r
: The root path from where to find the 'tests' directory - choices limited to.
(project root) andcjs
(ie. 'cjs' => 'cjs/tests') -
--simple/-s
: Use the 'progress' reporter instead of the default 'spec' -
--coverage/-c
: Activate coverage report (Istanbul) -
--help/-h
: Show this description
Note
Due to the way Karma reads the CLI arguments, unfortunately it is necessary to define multiple value as separate parameters instead of one list:
Won't work
npm test -- -t append addClass -b firefox chrome
Has to be written like this
npm test -- -t append -t addClass -b firefox -b chrome
Running all tests in all browsers
npm test
Running all tests in a specific browser
npm test -- -b firefox
Running a specific tests in a specific browser
npm test -- -b firefox -t append
Running a specific tests in multiple browsers
npm test -- -b firefox -b chrome -t append
Running multiple tests in multiple browsers
npm test -- -b firefox -b chrome -t append -t prepend
Running with coverage report
npm test -- -c
# With specific browser and test
npm test -- -cb firefox -t append
Running with the simple progress report
npm test -- -s
# With specific browser and test and coverage
npm test -- -scb firefox -t append
As the files are prebuild (and transpiled on IE browsers) debugging can be a tad hard,
so the spec
task has been included which compiles all the test files into the 'specs' folder.
In that way you can inspect the files as they are actually built at the time of testing:
npm run spec
CLI parameters
-
--instrument/-i
: Instrument the code with Istanbul. -
--root/-r
: Same as in test and it builds the CJS tests in the 'spec/cjs' directory. -
--help/-h
: Show this description
Main test files*
npm run spec
Main test files with instrumentation
npm run spec -- -i
CJS spec files
npm run spec -- -r cjs
CJS spec files with instrumentation
npm run spec -- -ir cjs