I am trying to configure karma and jasmine for Office Excel AddIn.
I have configuration like below:
// Karma configuration
// Generated on Fri Nov 26 2021 11:34:29 GMT+0800 (China Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
frameworks: ['jasmine', "karma-typescript"],
// list of files / patterns to load in the browser
files: [
'https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js',
'src/**/**.spec.ts'
],
plugins: [
require('karma-typescript'),
require('karma-coverage'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
],
client: {
clearContext: false,
jasmine: {
random: false,
seed: '0',
stopOnFailue: false
} // leave Jasmine Spec Runner output visible in browser
},
// list of files / patterns to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'src/**/*.ts': ["karma-typescript", 'coverage']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
reporters: ['progress', 'kjhtml', 'coverage', "karma-typescript"],
// optionally, configure the reporter
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
mime: {
'text/x-typescript': ['ts', 'tsx']
},
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true,
thresholds: {
statements: 80,
lines: 80,
branches: 80,
functions: 80
}
},
// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser instances should be started simultaneously
concurrency: Infinity
})
}
But it hit issue Some of your tests did a full page reload!
, and the result in webbrowser will be refreshed.