Skip to content

Commit

Permalink
test(client): Browserstack tests & more browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Feb 12, 2016
1 parent 574271c commit dfedc97
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 39 deletions.
93 changes: 64 additions & 29 deletions test/client/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,68 @@
var TRAVIS_WITHOUT_SAUCE = process.env.TRAVIS_SECURE_ENV_VARS === 'false'
var TRAVIS_WITHOUT_BS = process.env.TRAVIS_SECURE_ENV_VARS === 'false'

var launchers = {
sl_chrome: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 7',
version: '47'
bs_chrome: {
base: 'BrowserStack',
browser: 'chrome',
os: 'Windows',
os_version: '10'
},
sl_firefox: {
base: 'SauceLabs',
browserName: 'firefox',
version: '43'
bs_firefox: {
base: 'BrowserStack',
browser: 'firefox',
os: 'Windows',
os_version: '10'
},
sl_safari: {
base: 'SauceLabs',
browserName: 'safari',
version: '9',
platform: 'OS X 10.11'
bs_safari: {
base: 'BrowserStack',
browser: 'safari',
browser_version: '9.0',
os_version: 'El Capitan',
os: 'OS X'
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11'
bs_ie_11: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '11.0',
os: 'Windows',
os_version: '10'
},
sl_ie_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '10'
bs_ie_10: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '10.0',
os: 'Windows',
os_version: '8'
},
bs_ie_9: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '9.0',
os: 'Windows',
os_version: '7'
}
// TODO: Figure out why these fail on browserstack
// ,
// bs_ie_8: {
// base: 'BrowserStack',
// browser: 'ie',
// browser_version: '8.0',
// os: 'Windows',
// os_version: '7'
// },
// bs_ie_7: {
// base: 'BrowserStack',
// browser: 'ie',
// browser_version: '7.0',
// os: 'Windows',
// os_version: 'XP'
// }
}

var browsers = []

if (process.env.TRAVIS) {
if (TRAVIS_WITHOUT_SAUCE) {
if (TRAVIS_WITHOUT_BS) {
browsers.push('Firefox')
} else {
browsers = Object.keys(launchers)
Expand Down Expand Up @@ -67,7 +94,7 @@ module.exports = function (config) {
// use dots reporter, as travis terminal does not support escaping sequences
// possible values: 'dots', 'progress'
// CLI --reporters progress
reporters: ['progress', 'junit', 'saucelabs'],
reporters: ['progress', 'junit'],

junitReporter: {
// will be resolved to basePath (in the same way as files/exclude patterns)
Expand Down Expand Up @@ -122,7 +149,15 @@ module.exports = function (config) {
'karma-firefox-launcher',
'karma-junit-reporter',
'karma-browserify',
'karma-sauce-launcher'
]
'karma-browserstack-launcher'
],

concurrency: 3,

forceJSONP: true,

browserStack: {
project: 'Karma'
}
})
}
8 changes: 5 additions & 3 deletions test/client/karma.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,11 @@ describe('Karma', function () {

k.complete()

clock.tick(20)

assert.notEqual(iframe.src, CURRENT_URL)
// clock.tick() does not work in IE 7
setTimeout(function () {
clock.tick(1)
assert.notEqual(iframe.src, CURRENT_URL)
}, 10)
})

it('should not clear context window upon complete when clearContext config is false', function () {
Expand Down
21 changes: 14 additions & 7 deletions test/client/stringify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,38 @@ describe('stringify', function () {
assert(stringify(obj).indexOf("{a: 'a'}") > -1)

obj = {constructor: null}
assert(stringify(obj).indexOf('{constructor: null}') > -1)

// IE 7 serializes this to Object{}
var s = stringify(obj)
assert(s.indexOf('{constructor: null}') > -1 || s.indexOf('Object{}') > -1)

obj = Object.create(null)
obj.a = 'a'

assert(stringify(obj).indexOf("{a: 'a'}") > -1)
})

it('should serialize html', function () {
var div = document.createElement('div')

assert.deepEqual(stringify(div), '<div></div>')
assert.deepEqual(stringify(div).trim().toLowerCase(), '<div></div>')

div.innerHTML = 'some <span>text</span>'
assert.deepEqual(stringify(div), '<div>some <span>text</span></div>')
assert.deepEqual(stringify(div).trim().toLowerCase(), '<div>some <span>text</span></div>')
})

it('should serialize DOMParser objects', function () {
var parser = new DOMParser()
var doc = parser.parseFromString('<test></test>', 'application/xml')
assert.deepEqual(stringify(doc), '<test></test>')
if (typeof DOMParser !== 'undefined') {
// Test only works in IE 9 and above
var parser = new DOMParser()
var doc = parser.parseFromString('<test></test>', 'application/xml')
assert.deepEqual(stringify(doc), '<test></test>')
}
})

it('should serialize across iframes', function () {
var div = document.createElement('div')
assert.deepEqual(__karma__.stringify(div), '<div></div>')
assert.deepEqual(__karma__.stringify(div).trim().toLowerCase(), '<div></div>')

assert.deepEqual(__karma__.stringify([1, 2]), '[1, 2]')
})
Expand Down

0 comments on commit dfedc97

Please sign in to comment.