Commit e5a91870 authored by Mike Greiling's avatar Mike Greiling Committed by Clement Ho

Increase karma socket timeout

parent f2505eb6
...@@ -54,6 +54,7 @@ module.exports = function(config) { ...@@ -54,6 +54,7 @@ module.exports = function(config) {
subdir: '.', subdir: '.',
fixWebpackSourcePaths: true fixWebpackSourcePaths: true
}; };
karmaConfig.browserNoActivityTimeout = 60000; // 60 seconds
} }
if (process.env.DEBUG) { if (process.env.DEBUG) {
......
/* eslint-disable space-before-function-paren, no-unused-expressions, no-return-assign, no-param-reassign, no-var, new-cap, wrap-iife, no-unused-vars, quotes, jasmine/no-expect-in-setup-teardown, max-len */
/* global Project */ /* global Project */
import 'select2/select2'; import 'select2/select2';
...@@ -7,47 +6,52 @@ import '~/api'; ...@@ -7,47 +6,52 @@ import '~/api';
import '~/project_select'; import '~/project_select';
import '~/project'; import '~/project';
(function() { describe('Project Title', () => {
describe('Project Title', function() {
preloadFixtures('issues/open-issue.html.raw'); preloadFixtures('issues/open-issue.html.raw');
loadJSONFixtures('projects.json'); loadJSONFixtures('projects.json');
beforeEach(function() { beforeEach(() => {
loadFixtures('issues/open-issue.html.raw'); loadFixtures('issues/open-issue.html.raw');
window.gon = {}; window.gon = {};
window.gon.api_version = 'v3'; window.gon.api_version = 'v3';
return this.project = new Project(); // eslint-disable-next-line no-new
new Project();
}); });
describe('project list', function() { describe('project list', () => {
var fakeAjaxResponse = function fakeAjaxResponse(req) { let reqUrl;
var d; let reqData;
expect(req.url).toBe('/api/v3/projects.json?simple=true');
expect(req.data).toEqual({ search: '', order_by: 'last_activity_at', per_page: 20, membership: true }); beforeEach(() => {
d = $.Deferred(); const fakeResponseData = getJSONFixture('projects.json');
d.resolve(this.projects_data); spyOn(jQuery, 'ajax').and.callFake((req) => {
return d.promise(); const def = $.Deferred();
}; reqUrl = req.url;
reqData = req.data;
beforeEach((function(_this) { def.resolve(fakeResponseData);
return function() { return def.promise();
_this.projects_data = getJSONFixture('projects.json'); });
return spyOn(jQuery, 'ajax').and.callFake(fakeAjaxResponse.bind(_this)); });
};
})(this)); it('toggles dropdown', () => {
it('toggles dropdown', function() { const $menu = $('.js-dropdown-menu-projects');
var menu = $('.js-dropdown-menu-projects');
$('.js-projects-dropdown-toggle').click(); $('.js-projects-dropdown-toggle').click();
expect(menu).toHaveClass('open'); expect($menu).toHaveClass('open');
menu.find('.dropdown-menu-close-icon').click(); expect(reqUrl).toBe('/api/v3/projects.json?simple=true');
expect(menu).not.toHaveClass('open'); expect(reqData).toEqual({
search: '',
order_by: 'last_activity_at',
per_page: 20,
membership: true,
});
$menu.find('.dropdown-menu-close-icon').click();
expect($menu).not.toHaveClass('open');
}); });
}); });
afterEach(() => { afterEach(() => {
window.gon = {}; window.gon = {};
}); });
}); });
}).call(window);
...@@ -16,6 +16,14 @@ window.gl = window.gl || {}; ...@@ -16,6 +16,14 @@ window.gl = window.gl || {};
window.gl.TEST_HOST = 'http://test.host'; window.gl.TEST_HOST = 'http://test.host';
window.gon = window.gon || {}; window.gon = window.gon || {};
// HACK: Chrome 59 disconnects if there are too many synchronous tests in a row
// because it appears to lock up the thread that communicates to Karma's socket
// This async beforeEach gets called on every spec and releases the JS thread long
// enough for the socket to continue to communicate.
// The downside is that it creates a minor performance penalty in the time it takes
// to run our unit tests.
beforeEach(done => done()); // eslint-disable-line jasmine/no-global-setup
// render all of our tests // render all of our tests
const testsContext = require.context('.', true, /_spec$/); const testsContext = require.context('.', true, /_spec$/);
testsContext.keys().forEach(function (path) { testsContext.keys().forEach(function (path) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment