3.0.0 • Published 9 years ago
karma-config-rentpath v3.0.0
karma-config-rentpath
Shared Karma config for our apps
Installation
$ npm i --save-dev karma-config-rentpathUsage
The most minimal usage would be to create a karma.conf.js file in the root of your app with the following content:
module.exports = require('karma-config-rentpath')And then set up an entry file to load the tests at path /spec/javascripts/tests.bundle.js:
var context = require.context('.', true, /.+_spec\.(coffee|js|jsx)$/);
context.keys().forEach(context);
module.exports = context;If your app requires jasmine-jquery or jasmine-flight you will need to import them at the top of the entry file:
require('jasmine-jquery')
require('webpack-jasmine-flight')If your app has special needs, you'll want to apply the shared configuration then any custom configuration. For example:
var configure = require('karma-config-rentpath')
module.exports = function(config) {
// Apply shared configuration
configure(config)
// Custom app-specific configuration
config.files.push('some/extra/file')
}Running tests
Make sure your app's package.json has entries in scripts like these:
"test": "karma start --single-run",
"watch:test": "karma start",Kick off either of these with npm run (for example: npm run watch:test).
Note that the test script is a special name and can be run with these shortcuts:
# No need to say `run`:
npm test
# Or even more tersely:
npm tScripts
npm run compile- Compiles the module to disk (~/lib).npm run compile:watch- Same asnpm run compilebut watches files for changes.npm run lint- Lints all files.npm run lint:fix- Lints all files and attempts to fix any issues.npm run test- Runs unit tests.npm run test:watch- Same asnpm testbut watches files for changes.npm run test:cov- Generates a test coverage report.
Distribution
Execute one of the following commands
npm version patch -m "Bumped to %s"
npm version minor -m "Bumped to %s"
npm version major -m "Bumped to %s"