Skip to content

Commit 7aafa62

Browse files
author
Shahak Yosef
committed
Merged PR 139686: Add kjhtml
Add kjhtml to the Javascript SDK to make debugging tests easier. ## Know issues: 1) An old version (0.2.2) is used because newer versions are incompatible with our jasmine karma versions, trying to update them causes issues both in the tests themselves and in test coverage reporting. 2) Closing the test page doesn't close the running command in the terminal, need a couple of `cntrl + c`, this is the same in other repositories. For reference check [karma.baseconf.js](https://powerbi.visualstudio.com/PowerBIClients/_git/PowerBIClients?path=%2Fsrc%2FModern%2FIntegrationTesting%2FDesktopIntegrationTestHost%2Fkarma.baseconf.js&_a=contents&version=GBmaster) and [karma.conf.js](https://powerbi.visualstudio.com/PowerBIClients/_git/PowerBIClients?path=%2Fsrc%2FClients%2FPowerBIPlayground%2FAngular%2Fkarma.conf.js&_a=contents&version=GBmaster) ![khjtml.PNG](https://powerbi.visualstudio.com/4c7b5adb-c2d0-4f18-b23c-edc4ac30f4e1/_apis/git/repositories/1dd63332-e003-46a3-ac6f-70213a1bcc2e/pullRequests/139686/attachments/khjtml.PNG)
1 parent 5157b61 commit 7aafa62

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,7 @@ gulp.task('test:js', 'Run js tests', function (done) {
211211
configFile: __dirname + '/karma.conf.js',
212212
singleRun: argv.watch ? false : true,
213213
captureTimeout: argv.timeout || 60000
214-
}, done).start();
214+
}, function() {
215+
done();
216+
}).start();
215217
});

karma.conf.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ var argv = require('yargs').argv;
22

33
var browserName = 'PhantomJS';
44
if (argv.chrome) {
5-
browserName = 'Chrome'
5+
browserName = 'Chrome_headless'
66
}
77
else if (argv.firefox) {
88
browserName = 'Firefox'
99
}
10-
10+
const flags = [
11+
'--disable-gpu',
12+
'--disable-extensions',
13+
'--no-proxy-server',
14+
'--js-flags="--max_old_space_size=6500"',
15+
'--high-dpi-support=1',
16+
];
1117
module.exports = function (config) {
1218
config.set({
1319
frameworks: ['jasmine'],
@@ -18,7 +24,7 @@ module.exports = function (config) {
1824
{ pattern: './test/**/*.html', served: true, included: false }
1925
],
2026
exclude: [],
21-
reporters: argv.debug ? ['spec'] : ['spec', 'coverage'],
27+
reporters: argv.debug ? ['spec', 'kjhtml'] : ['spec', 'coverage', 'kjhtml'],
2228
autoWatch: true,
2329
browsers: [browserName],
2430
plugins: [
@@ -27,8 +33,15 @@ module.exports = function (config) {
2733
'karma-jasmine',
2834
'karma-spec-reporter',
2935
'karma-phantomjs-launcher',
30-
'karma-coverage'
36+
'karma-coverage',
37+
'karma-jasmine-html-reporter',
3138
],
39+
customLaunchers: {
40+
'Chrome_headless': {
41+
base: 'Chrome',
42+
flags: flags.concat("--no-sandbox", "--window-size=800,800"),
43+
},
44+
},
3245
preprocessors: { './tmp/**/*.js': ['coverage'] },
3346
coverageReporter: {
3447
reporters: [
@@ -37,7 +50,9 @@ module.exports = function (config) {
3750
]
3851
},
3952
logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO,
53+
retryLimit: 0,
4054
client: {
55+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
4156
args: argv.logMessages ? ['logMessages'] : []
4257
}
4358
});

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"start": "http-server ./demo",
1616
"prestart": "cd demo && npm install",
1717
"test": "gulp test",
18-
"gulp": "gulp"
18+
"gulp": "gulp",
19+
"testc": "npm test -- --chrome --watch"
1920
},
2021
"keywords": [
2122
"microsoft",
@@ -65,6 +66,7 @@
6566
"karma-coverage": "^2.0.3",
6667
"karma-firefox-launcher": "^1.2.0",
6768
"karma-jasmine": "^0.3.8",
69+
"karma-jasmine-html-reporter": "^0.2.2",
6870
"karma-phantomjs-launcher": "^1.0.4",
6971
"karma-spec-reporter": "0.0.32",
7072
"moment": "^2.14.1",

0 commit comments

Comments
 (0)