Skip to content

Commit

Permalink
Add codecoverage
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Nov 16, 2018
1 parent 1b8bf06 commit ad459b9
Show file tree
Hide file tree
Showing 7 changed files with 840 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -26,8 +26,8 @@ before_install:
script:
- npm run lint
- sleep 10
- make browser
- make test

after_script:
- codecov
- docker logs $DOCKER_ID
5 changes: 1 addition & 4 deletions Makefile
Expand Up @@ -6,7 +6,7 @@ ifndef VERBOSE
.SILENT:
endif

.PHONY: all browser
.PHONY: all

all: deps
if [ ! -f owncloud/test/config.json ] ; then cp owncloud/test/config.sample.json owncloud/test/config.json ; fi;
Expand Down Expand Up @@ -52,9 +52,6 @@ jsdocs:
#Output the final documentation link
echo "To read the documentation, click here : file://"${DIR}"/jsdoc/ownCloud.html"

browser: deps
node_modules/.bin/webpack

clean:
#Delete existing documentation
rm -rf jsdoc/
Expand Down
177 changes: 98 additions & 79 deletions karma.conf.js
@@ -1,82 +1,101 @@
var webpackConfig = require('./webpack.config.js');
const path = require('path')

module.exports = function (config) {
var ownCloudConfig = require('./owncloud/test/config.json');
config.set({

client: {
ownCloudConfig: ownCloudConfig,
jasmine: {
random: false,
var ownCloudConfig = require('./owncloud/test/config.json')
config.set({

client: {
ownCloudConfig: ownCloudConfig,
jasmine: {
random: false
}
},

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
'tests/karma.js',
'node_modules/utf8/utf8.js',
'tests/unauthenticated/*Test.js',
'tests/*.js'
],

// list of files / patterns to exclude
exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'tests/karma.js': ['webpack']
},

webpack: {
output: {
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.json']
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: [ path.resolve(__dirname, 'test'), /node_modules/ ],
enforce: 'post',
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
},

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
'node_modules/utf8/utf8.js',
'browser/toBundle.js',
'tests/unauthenticated/*Test.js',
'tests/*.js'
],

// list of files / patterns to exclude
exclude: webpackConfig,


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./browser/toBundle.js': ['webpack']
},

webpack: {},

webpackMiddleware: {
noInfo: true
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// 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,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless', 'Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
}
]
}
},

webpackMiddleware: {
noInfo: true
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots', 'coverage-istanbul'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// 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,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless', 'Chrome'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,

coverageIstanbulReporter: {
reports: [ 'lcovonly', 'text' ],
dir: path.join(__dirname, 'coverage'),
fixWebpackSourcePaths: true
}
})
}
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -37,19 +37,23 @@
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine": "2.99",
"jasmine-core": "2.99",
"jsdoc": "^3.4.3",
"jszip": "^3.1.3",
"karma": "^3.1.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "^1.1.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.5",
"utf8": "^3.0.0",
"webpack": "^3.0.0"
},
"dependencies": {
"browser-request": "^0.3.3",
"codecov": "^3.1.0",
"promise": "^8.0.0",
"xml-js": "^1.3.2"
}
Expand Down
7 changes: 7 additions & 0 deletions tests/karma.js
@@ -0,0 +1,7 @@
/* eslint-disable new-cap */
var owncloud = require('../owncloud/index.js')
var oc = new owncloud()

window.oc = oc
window.ownCloud = owncloud
window.OwnCloud = owncloud
7 changes: 0 additions & 7 deletions webpack.config.js

This file was deleted.

0 comments on commit ad459b9

Please sign in to comment.