diff options
author | Mike Greiling <mgreiling@gitlab.com> | 2017-06-16 23:40:28 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-06-16 23:40:28 +0300 |
commit | e5a91870fd2a4eefd086aa88e3b5ea02e2fbc768 (patch) | |
tree | 53855e8f6ae27bf5ff5f1db6fe9b4e1d2c25c74b | |
parent | f2505eb6ce87877f78ee90c8567f879bcd77642b (diff) |
Increase karma socket timeout
-rw-r--r-- | config/karma.config.js | 1 | ||||
-rw-r--r-- | spec/javascripts/project_title_spec.js | 76 | ||||
-rw-r--r-- | spec/javascripts/test_bundle.js | 8 |
3 files changed, 49 insertions, 36 deletions
diff --git a/config/karma.config.js b/config/karma.config.js index 978850e5d70..5911a9a7e10 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -54,6 +54,7 @@ module.exports = function(config) { subdir: '.', fixWebpackSourcePaths: true }; + karmaConfig.browserNoActivityTimeout = 60000; // 60 seconds } if (process.env.DEBUG) { diff --git a/spec/javascripts/project_title_spec.js b/spec/javascripts/project_title_spec.js index 3dba2e817ff..cc336180ff7 100644 --- a/spec/javascripts/project_title_spec.js +++ b/spec/javascripts/project_title_spec.js @@ -1,4 +1,3 @@ -/* 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 */ import 'select2/select2'; @@ -7,47 +6,52 @@ import '~/api'; import '~/project_select'; import '~/project'; -(function() { - describe('Project Title', function() { - preloadFixtures('issues/open-issue.html.raw'); - loadJSONFixtures('projects.json'); +describe('Project Title', () => { + preloadFixtures('issues/open-issue.html.raw'); + loadJSONFixtures('projects.json'); - beforeEach(function() { - loadFixtures('issues/open-issue.html.raw'); + beforeEach(() => { + loadFixtures('issues/open-issue.html.raw'); - window.gon = {}; - window.gon.api_version = 'v3'; + window.gon = {}; + window.gon.api_version = 'v3'; - return this.project = new Project(); - }); + // eslint-disable-next-line no-new + new Project(); + }); - describe('project list', function() { - var fakeAjaxResponse = function fakeAjaxResponse(req) { - var d; - 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 }); - d = $.Deferred(); - d.resolve(this.projects_data); - return d.promise(); - }; - - beforeEach((function(_this) { - return function() { - _this.projects_data = getJSONFixture('projects.json'); - return spyOn(jQuery, 'ajax').and.callFake(fakeAjaxResponse.bind(_this)); - }; - })(this)); - it('toggles dropdown', function() { - var menu = $('.js-dropdown-menu-projects'); - $('.js-projects-dropdown-toggle').click(); - expect(menu).toHaveClass('open'); - menu.find('.dropdown-menu-close-icon').click(); - expect(menu).not.toHaveClass('open'); + describe('project list', () => { + let reqUrl; + let reqData; + + beforeEach(() => { + const fakeResponseData = getJSONFixture('projects.json'); + spyOn(jQuery, 'ajax').and.callFake((req) => { + const def = $.Deferred(); + reqUrl = req.url; + reqData = req.data; + def.resolve(fakeResponseData); + return def.promise(); }); }); - afterEach(() => { - window.gon = {}; + it('toggles dropdown', () => { + const $menu = $('.js-dropdown-menu-projects'); + $('.js-projects-dropdown-toggle').click(); + expect($menu).toHaveClass('open'); + expect(reqUrl).toBe('/api/v3/projects.json?simple=true'); + 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'); }); }); -}).call(window); + + afterEach(() => { + window.gon = {}; + }); +}); diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 2c34402576b..729db02e06c 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -16,6 +16,14 @@ window.gl = window.gl || {}; window.gl.TEST_HOST = 'http://test.host'; 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 const testsContext = require.context('.', true, /_spec$/); testsContext.keys().forEach(function (path) { |