Run Jasmine tests using Karma and PhantomJS in a Docker container.
docker run --rm -it -v $PWD:/opt/karma hochzehn/karma-jasmine-phantomjs
Run this from your project root directory, or wherever your karma.conf.js
is located.
This container supports junit report generation. Apply in karma.conf.js
like this:
reporters: ['junit'],
junitReporter: {
outputDir: 'test-reports/',
outputFile: 'junit.xml',
useBrowserName: false
}
This container supports code coverage. Apply in karma.conf.js
like this:
reporters: ['coverage'],
preprocessors: {
'path/to/src/**.js': 'coverage'
},
coverageReporter: {
reporters: [
{ type: 'text-summary' },
{ type: 'html', dir: 'test-reports' },
{ type: 'clover', dir: 'test-reports', subdir: '.', file: 'clover.xml' }
]
},
You probably want to ignore /test-reports
from your CVS as well.
docker build -t karma-jasmine-phantomjs .
docker run --rm -it -v $PWD:/opt/karma karma-jasmine-phantomjs