-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding tests * karma setup * got tests working * mocking working * set up coverage * cleaned up commit * moved tasks to appropriate places * added task for jenkins * change jenkins to cproc * testing jenkins build * testing builds * combined testing * finished build error * fixed testing reporting
- Loading branch information
Anthony Dresser
authored
Nov 17, 2016
1 parent
d7fc17b
commit 2e24ff2
Showing
34 changed files
with
1,829 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ packages | |
tools | ||
examples | ||
sqltoolsservice | ||
coverage/ | ||
coverage | ||
test-reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// #docregion | ||
// /*global jasmine, __karma__, window*/ | ||
Error.stackTraceLimit = 0; // "No stacktrace"" is usually best for app testing. | ||
|
||
// Uncomment to get full stacktrace output. Sometimes helpful, usually not. | ||
Error.stackTraceLimit = Infinity; // | ||
|
||
var builtPath = '/base/out/src/views/htmlcontent/dist/js/'; | ||
|
||
__karma__.loaded = function () { }; | ||
|
||
function isJsFile(path) { | ||
return path.slice(-3) == '.js'; | ||
} | ||
|
||
function isSpecFile(path) { | ||
return /\.spec\.(.*\.)?js$/.test(path); | ||
} | ||
|
||
function isBuiltFile(path) { | ||
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); | ||
} | ||
|
||
var allSpecFiles = Object.keys(window.__karma__.files) | ||
.filter(isSpecFile); | ||
|
||
System.config({ | ||
baseURL: 'base/out/src/views/htmlcontent', | ||
// Extend usual application package list with test folder | ||
packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } }, | ||
|
||
// Assume npm: is set in `paths` in systemjs.config | ||
// Map the angular testing umd bundles | ||
map: { | ||
'@angular/core/testing': 'lib/js/@angular/core/bundles/core-testing.umd.js', | ||
'@angular/common/testing': 'lib/js/@angular/common/bundles/common-testing.umd.js', | ||
'@angular/compiler/testing': 'lib/js/@angular/compiler/bundles/compiler-testing.umd.js', | ||
'@angular/platform-browser/testing': 'lib/js/@angular/platform-browser/bundles/platform-browser-testing.umd.js', | ||
'@angular/platform-browser-dynamic/testing': 'lib/js/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', | ||
'@angular/http/testing': 'lib/js/@angular/http/bundles/http-testing.umd.js', | ||
'@angular/router/testing': 'lib/js/@angular/router/bundles/router-testing.umd.js', | ||
'@angular/forms/testing': 'ib/js/@angular/forms/bundles/forms-testing.umd.js', | ||
}, | ||
}); | ||
|
||
System.import('lib/js/systemjs.config.js') | ||
.then(importSystemJsExtras) | ||
.then(initTestBed) | ||
.then(initTesting); | ||
|
||
/** Optional SystemJS configuration extras. Keep going w/o it */ | ||
function importSystemJsExtras(){ | ||
return System.import('lib/js/systemjs.config.extras.js') | ||
.catch(function(reason) { | ||
console.log( | ||
'Warning: System.import could not load the optional "systemjs.config.extras.js". Did you omit it by accident? Continuing without it.' | ||
); | ||
console.log(reason); | ||
}); | ||
} | ||
|
||
function initTestBed(){ | ||
return Promise.all([ | ||
System.import('@angular/core/testing'), | ||
System.import('@angular/platform-browser-dynamic/testing') | ||
]) | ||
|
||
.then(function (providers) { | ||
var coreTesting = providers[0]; | ||
var browserTesting = providers[1]; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; | ||
|
||
coreTesting.TestBed.initTestEnvironment( | ||
browserTesting.BrowserDynamicTestingModule, | ||
browserTesting.platformBrowserDynamicTesting()); | ||
}) | ||
} | ||
|
||
// Import all spec files and start karma | ||
function initTesting () { | ||
return Promise.all( | ||
allSpecFiles.map(function (moduleName) { | ||
return System.import(moduleName); | ||
}) | ||
) | ||
.then(__karma__.start, __karma__.error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// #docregion | ||
const path = require('path'); | ||
|
||
module.exports = function(config) { | ||
|
||
var appBase = 'out/src/views/htmlcontent/dist/'; // transpiled app JS and map files | ||
var appSrcBase = 'src/views/htmlcontent/src/js/'; // app source TS files | ||
var appAssets = 'base/out/src/views/htmlcontent/'; // component assets fetched by Angular's compiler | ||
|
||
var testBase = 'out/test/angular/'; // transpiled test JS and map files | ||
var testSrcBase = 'test/angular/'; // test source TS files | ||
|
||
config.set({ | ||
basePath: path.join(__dirname), | ||
frameworks: ['jasmine'], | ||
plugins: [ | ||
require('karma-remap-istanbul'), | ||
require('karma-coverage'), | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), // click "Debug" in browser to see it | ||
require('karma-htmlfile-reporter'), // crashing w/ strange socket error | ||
require('karma-junit-reporter') | ||
], | ||
|
||
customLaunchers: { | ||
// From the CLI. Not used here but interesting | ||
// chrome setup for travis CI using chromium | ||
Chrome_travis_ci: { | ||
base: 'Chrome', | ||
flags: ['--no-sandbox'] | ||
} | ||
}, | ||
files: [ | ||
'out/src/views/htmlcontent/lib/js/jquery-1.7.min.js', | ||
'out/src/views/htmlcontent/lib/js/jquery.event.drag-2.2.js', | ||
'out/src/views/htmlcontent/lib/js/jquery-ui-1.8.16.custom.min.js', | ||
'out/src/views/htmlcontent/lib/js/underscore-min.js', | ||
'out/src/views/htmlcontent/lib/js/slick.core.js', | ||
'out/src/views/htmlcontent/lib/js/slick.grid.js', | ||
'out/src/views/htmlcontent/lib/js/slick.editors.js', | ||
'out/src/views/htmlcontent/lib/js/slick.autosizecolumn.js', | ||
'out/src/views/htmlcontent/lib/js/slick.dragrowselector.js', | ||
// System.js for module loading | ||
'out/src/views/htmlcontent/lib/js/system.src.js', | ||
|
||
// Polyfills | ||
'out/src/views/htmlcontent/lib/js/shim.min.js', | ||
'out/src/views/htmlcontent/lib/js/Reflect.js', | ||
|
||
// zone.js | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/zone.js', | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/long-stack-trace-zone.js', | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/proxy.js', | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/sync-test.js', | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/jasmine-patch.js', | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/async-test.js', | ||
'out/src/views/htmlcontent/lib/js/zone.js/dist/fake-async-test.js', | ||
|
||
// RxJs | ||
{ pattern: 'out/src/views/htmlcontent/lib/js/rxjs/**/*.js', included: false, watched: false }, | ||
{ pattern: 'out/src/views/htmlcontent/lib/js/rxjs/**/*.js.map', included: false, watched: false }, | ||
|
||
|
||
{ pattern: 'out/src/views/htmlcontent/lib/js/angular2-slickgrid/**/*.js', included: false, watched: false }, | ||
{ pattern: 'out/src/views/htmlcontent/lib/js/angular2-slickgrid/**/*.js.map', included: false, watched: false }, | ||
|
||
{ pattern: 'out/src/views/htmlcontent/lib/js/json.js', included: false, watched: false}, | ||
|
||
// Paths loaded via module imports: | ||
// Angular itself | ||
{ pattern: 'out/src/views/htmlcontent/lib/js/@angular/**/*.js', included: false, watched: false }, | ||
{ pattern: 'out/src/views/htmlcontent/lib/js/@angular/**/*.js.map', included: false, watched: false }, | ||
|
||
{ pattern: 'out/src/views/htmlcontent/lib/js/systemjs.config.js', included: false, watched: false }, | ||
{ pattern: 'out/src/views/htmlcontent/lib/js/systemjs.config.extras.js', included: false, watched: false }, | ||
'karma-test-shim.js', | ||
|
||
// transpiled application & spec code paths loaded via module imports | ||
{ pattern: appBase + '**/*.js', included: false, watched: true }, | ||
{ pattern: appBase + '**/*.json', included: false, watched: false }, | ||
{ pattern: testBase + '**/*.js', included: false, watched: false }, | ||
|
||
|
||
// Asset (HTML & CSS) paths loaded via Angular's component compiler | ||
// (these paths need to be rewritten, see proxies section) | ||
{ pattern: appBase + '**/*.html', included: false, watched: false }, | ||
{ pattern: appBase + '**/*.css', included: false, watched: false }, | ||
|
||
// Paths for debugging with source maps in dev tools | ||
{ pattern: appSrcBase + '**/*.ts', included: false, watched: false }, | ||
{ pattern: appBase + '**/*.js.map', included: false, watched: false }, | ||
{ pattern: testSrcBase + '**/*.ts', included: false, watched: false }, | ||
{ pattern: testBase + '**/*.js.map', included: false, watched: false } | ||
], | ||
|
||
// Proxied base paths for loading assets | ||
proxies: { | ||
// required for component assets fetched by Angular's compiler | ||
"/dist/": 'base/out/src/views/htmlcontent/dist/' | ||
}, | ||
|
||
exclude: [], | ||
preprocessors: { | ||
'out/src/views/htmlcontent/dist/**/!(*spec)*.js': 'coverage', | ||
}, | ||
// disabled HtmlReporter; suddenly crashing w/ strange socket error | ||
reporters: ['progress', 'coverage', 'karma-remap-istanbul', 'junit'],//'html'], | ||
|
||
// HtmlReporter configuration | ||
htmlReporter: { | ||
// Open this file to see results in browser | ||
outputFile: '_test-output/tests.html', | ||
|
||
// Optional | ||
pageTitle: 'Unit Tests', | ||
subPageTitle: __dirname | ||
}, | ||
coverageReporter: { | ||
dir : 'coverage/', | ||
reporters: [ | ||
{type: 'json'} | ||
] | ||
}, | ||
remapIstanbulReporter: { | ||
reports: { | ||
json: 'coverage/coverage-html.json' | ||
} | ||
}, | ||
junitReporter: { | ||
outputDir: 'test-reports/' | ||
}, | ||
|
||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: true | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.