From b44665e75d7a351d50dd75e6ea3bb49b4e901fd1 Mon Sep 17 00:00:00 2001 From: alecmerdler Date: Fri, 6 Jan 2017 21:27:54 -0800 Subject: [PATCH] installed and configured karma test runner --- .dockerignore | 1 + .gitignore | 1 + karma.conf.js | 69 +++++++++++++++++++ package.json | 40 ++++++++--- .../test/services/angular-view-array.spec.js | 13 ++++ static/test/shims/window.shim.js | 30 ++++++++ 6 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 karma.conf.js create mode 100644 static/test/services/angular-view-array.spec.js create mode 100644 static/test/shims/window.shim.js diff --git a/.dockerignore b/.dockerignore index cd4ba187b..5a266e8e1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,5 +16,6 @@ run-local.sh .tox htmlcov .coverage +coverage .cache test/__pycache__ diff --git a/.gitignore b/.gitignore index e2aa3f78b..d5d39119f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ GIT_HEAD .python-version .pylintrc .coverage +coverage htmlcov .tox .cache diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 000000000..be0b206da --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,69 @@ +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine'], + files: [ + // CDN resources + 'node_modules/jquery/dist/jquery.js', + 'node_modules/angular/angular.js', + 'node_modules/angular-animate/angular-animate.js', + 'node_modules/angular-cookies/angular-cookies.js', + 'node_modules/angular-md5/angular-md5.js', + 'node_modules/angular-mocks/angular-mocks.js', + 'node_modules/angular-route/angular-route.js', + 'node_modules/angular-sanitize/angular-sanitize.js', + 'node_modules/moment/moment.js', + 'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.js', + 'node_modules/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js', + 'node_modules/bootbox/bootbox.js', + 'node_modules/underscore/underscore.js', + 'node_modules/restangular/dist/restangular.js', + 'node_modules/d3/d3.js', + 'node_modules/raven-js/dist/raven.js', + 'node_modules/cal-heatmap/cal-heatmap.js', + + // static/lib resources + 'static/lib/**/*.js', + + // FIXME: Upgrade angular-file-upload -> ng-file-upload + 'https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/1.4.0/angular-file-upload.js', + 'https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/1.4.0/angular-file-upload-html5-shim.js', + + // Application resources + 'static/js/tour.js', + 'static/js/core-ui.js', + 'static/js/core-config-setup.js', + 'static/js/app.js', + 'static/js/**/*.js', + + // Tests + 'static/test/**/*.js', + ], + exclude: [ + 'static/js/build/bundle.js', + ], + preprocessors: { + 'static/lib/ngReact/react.ngReact.min.js': ['webpack'], + 'static/lib/angular-moment.min.js': ['webpack'], + }, + webpack: {}, + webpackMiddleware: { + stats: 'errors-only' + }, + reporters: ['dots', 'coverage'], + coverageReporter: { + dir: 'coverage', + type: 'html' + }, + client: { + captureConsole: true + }, + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['PhantomJS', 'Chrome'], + singleRun: false, + concurrency: Infinity + }); +}; diff --git a/package.json b/package.json index 24906dac4..d9a23d7eb 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "version": "1.0.0", "scripts": { + "test": "./node_modules/.bin/karma start --single-run --browsers PhantomJS", "build": "./node_modules/.bin/webpack --progress -p -v", "watch": "./node_modules/.bin/webpack --watch" }, @@ -16,20 +17,39 @@ "@types/angular": "1.5.16", "@types/react": "0.14.39", "@types/react-dom": "0.14.17", - "angular": "1.5.8", - "moment": "2.16.0", - "ngreact": "0.3.0", - "react": "15.3.2", - "react-dom": "15.3.2", - "typescript": "2.0.3" + "angular": "1.5.3", + "angular-animate": "^1.5.3", + "angular-cookies": "^1.5.3", + "angular-route": "^1.5.3", + "angular-sanitize": "^1.5.3", + "bootbox": "^4.1.0", + "bootstrap": "^3.3.2", + "bootstrap-datepicker": "^1.6.4", + "cal-heatmap": "^3.3.10", + "d3": "^3.3.3", + "eonasdan-bootstrap-datetimepicker": "^4.17.43", + "jquery": "1.12.4", + "raven-js": "^3.1.0", + "react": "^15.3.2", + "react-dom": "^15.3.2", + "restangular": "^1.2.0", + "underscore": "^1.5.2" }, "devDependencies": { - "css-loader": "0.25.0", + "angular-mocks": "^1.5.3", + "jasmine-core": "^2.5.2", + "karma": "^0.13.22", + "karma-chrome-launcher": "^2.0.0", + "karma-coverage": "^0.5.5", + "karma-es6-shim": "^1.0.0", + "karma-intl-shim": "^1.0.3", + "karma-jasmine": "^0.3.8", + "karma-phantomjs-launcher": "^1.0.0", + "karma-webpack": "^1.8.1", "node-sass": "3.10.1", - "sass-loader": "4.0.2", - "source-map-loader": "0.1.5", - "style-loader": "0.13.1", + "phantomjs-prebuilt": "^2.1.7", "ts-loader": "0.9.5", + "typescript": "2.0.3", "typings": "1.4.0", "webpack": "1.13.3" } diff --git a/static/test/services/angular-view-array.spec.js b/static/test/services/angular-view-array.spec.js new file mode 100644 index 000000000..88d8d3f3b --- /dev/null +++ b/static/test/services/angular-view-array.spec.js @@ -0,0 +1,13 @@ +describe("Service: AngularViewArray", function() { + var angularViewArray; + + beforeEach(module('quay')); + + beforeEach(inject(function($injector) { + angularViewArray = $injector.get('AngularViewArray'); + })); + + it("sanity test", function() { + expect(angularViewArray.create).toBeDefined(); + }); +}); \ No newline at end of file diff --git a/static/test/shims/window.shim.js b/static/test/shims/window.shim.js new file mode 100644 index 000000000..3f59c01c3 --- /dev/null +++ b/static/test/shims/window.shim.js @@ -0,0 +1,30 @@ +// Add properties to window object used by 'app.js' to avoid test errors + +window.__config = { + 'SERVER_HOSTNAME': "", + 'PREFERRED_URL_SCHEME': "", +}; +window.__features = {}; +window.__oauth = { + 'GITHUB_TRIGGER_CONFIG': { + 'CLIENT_ID': "", + 'GITHUB_ENDPOINT': "", + 'AUTHORIZE_ENDPOINT': "", + }, + 'GITLAB_TRIGGER_CONFIG': { + 'CLIENT_ID': "", + 'GITLAB_ENDPOINT': "", + 'AUTHORIZE_ENDPOINT': "", + } +}; +window.__endpoints = { + "/api/v1/user/": { + "get": { + "operationId": "getLoggedInUser", + "parameters": [] + }, + "x-name": "endpoints.api.user.User", + "x-path": "/api/v1/user/", + "x-tag": "user" + }, +};