From a8078d629e50ec1ea0e562e24e7bd7ea8931d896 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Fri, 6 Jan 2017 18:19:42 -0600 Subject: [PATCH] migrate all tests into a single webpack bundle --- config/karma.config.js | 3 +-- spec/javascripts/.eslintrc | 5 +++-- .../{spec_helper.js => test_bundle.js} | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) rename spec/javascripts/{spec_helper.js => test_bundle.js} (76%) diff --git a/config/karma.config.js b/config/karma.config.js index 96d33490b37..b317c3f00b2 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -8,8 +8,7 @@ module.exports = function(config) { basePath: ROOT_PATH, frameworks: ['jasmine'], files: [ - 'spec/javascripts/spec_helper.js', - 'spec/javascripts/**/*_spec.js?(.es6)', + 'spec/javascripts/test_bundle.js', { pattern: 'spec/javascripts/fixtures/**/*@(.json|.html|.html.raw)', included: false }, ], preprocessors: { diff --git a/spec/javascripts/.eslintrc b/spec/javascripts/.eslintrc index dcbcd014dc3..b3d191e15ab 100644 --- a/spec/javascripts/.eslintrc +++ b/spec/javascripts/.eslintrc @@ -22,7 +22,8 @@ }, "plugins": ["jasmine"], "rules": { - "prefer-arrow-callback": 0, - "func-names": 0 + "func-names": 0, + "no-console": 0, + "prefer-arrow-callback": 0 } } diff --git a/spec/javascripts/spec_helper.js b/spec/javascripts/test_bundle.js similarity index 76% rename from spec/javascripts/spec_helper.js rename to spec/javascripts/test_bundle.js index b55f08e3311..cbe8abbbc08 100644 --- a/spec/javascripts/spec_helper.js +++ b/spec/javascripts/test_bundle.js @@ -1,5 +1,9 @@ +// enable test fixtures require('jasmine-jquery'); +jasmine.getFixtures().fixturesPath = 'base/spec/javascripts/fixtures'; +jasmine.getJSONFixtures().fixturesPath = 'base/spec/javascripts/fixtures'; + // include common libraries window.$ = window.jQuery = require('jquery'); window._ = require('underscore'); @@ -21,11 +25,18 @@ require('bootstrap/js/transition'); require('bootstrap/js/tooltip'); require('bootstrap/js/popover'); -// configure jasmine -jasmine.getFixtures().fixturesPath = 'base/spec/javascripts/fixtures'; -jasmine.getJSONFixtures().fixturesPath = 'base/spec/javascripts/fixtures'; - // stub expected globals window.gl = window.gl || {}; window.gl.TEST_HOST = 'http://test.host'; window.gon = window.gon || {}; + +// render all of our tests +const testsContext = require.context('.', true, /_spec$/); +testsContext.keys().forEach(function (path) { + try { + testsContext(path); + } catch (err) { + console.error('[ERROR] WITH SPEC FILE: ', path); + console.error(err); + } +});