Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 39f8e57

Browse files
authored
Merge pull request #91 from segmentio/fix/flaky-tests/2
Fix flaky test - Attempt 2
2 parents 51ecb87 + 72e55bc commit 39f8e57

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

karma.conf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
/* eslint-env node */
22
'use strict';
33

4+
// 10 minutes
5+
var TEST_TIMEOUT = 10 * 60 * 1000;
6+
47
module.exports = function(config) {
58
config.set({
69
files: [
710
{ pattern: 'test/support/*.html', included: false },
811
'test/support/global.js', // NOTE: This must run before all tests
912
'test/**/*.test.js'
1013
],
11-
1214
browsers: ['PhantomJS'],
1315

1416
frameworks: ['browserify', 'mocha'],
@@ -19,9 +21,12 @@ module.exports = function(config) {
1921
'test/**/*.js': 'browserify'
2022
},
2123

24+
browserNoActivityTimeout: TEST_TIMEOUT,
25+
2226
client: {
2327
mocha: {
24-
grep: process.env.GREP
28+
grep: process.env.GREP,
29+
timeout: TEST_TIMEOUT
2530
}
2631
},
2732

test/cookie.test.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ describe('cookie', function() {
88
// Just to make sure that
99
// URIError is never thrown here.
1010
document.cookie = 'bad=%';
11-
12-
// enable debugging for cookie package so we can better
13-
// observe flaky tests on IE/Edge.
14-
window.localStorage.setItem('debug', 'cookie');
1511
});
1612

1713
afterEach(function() {
1814
// reset to defaults
1915
cookie.options({});
20-
cookie.remove('x');
16+
// remove all cookies
17+
document.cookie.split(';').forEach(function(entry) {
18+
cookie.remove(entry.split('=')[0]);
19+
});
2120
});
2221

2322
describe('#get', function() {
@@ -26,32 +25,29 @@ describe('cookie', function() {
2625
});
2726

2827
it('should get an existing cookie', function() {
29-
cookie.set('x', { a: 'b' });
30-
assert.deepEqual(cookie.get('x'), { a: 'b' });
28+
cookie.set('cookie-get', { a: 'b' });
29+
assert.deepEqual(cookie.get('cookie-get'), { a: 'b' });
3130
});
3231

3332
it('should not throw an error on a malformed cookie', function() {
34-
document.cookie = 'x=y';
35-
assert(cookie.get('x') === null);
33+
document.cookie = 'cookie-bad=y';
34+
assert(cookie.get('cookie-bad') === null);
3635
});
3736
});
3837

3938
describe('#set', function() {
4039
it('should set a cookie', function() {
41-
// Logging so we can better observe flaky tests on IE/Edge.
42-
console.log('setting cookie. document.cookie is', document.cookie);
43-
cookie.set('x', { a: 'b' });
44-
console.log('cookie set. document.cookie is', document.cookie);
45-
assert.deepEqual(cookie.get('x'), { a: 'b' });
40+
cookie.set('cookie-set', { a: 'b' });
41+
assert.deepEqual(cookie.get('cookie-set'), { a: 'b' });
4642
});
4743
});
4844

4945
describe('#remove', function() {
5046
it('should remove a cookie', function() {
51-
cookie.set('x', { a: 'b' });
52-
assert.deepEqual(cookie.get('x'), { a: 'b' });
53-
cookie.remove('x');
54-
assert(cookie.get('x') === null);
47+
cookie.set('cookie-remove', { a: 'b' });
48+
assert.deepEqual(cookie.get('cookie-remove'), { a: 'b' });
49+
cookie.remove('cookie-remove');
50+
assert(cookie.get('cookie-remove') === null);
5551
});
5652
});
5753

0 commit comments

Comments
 (0)