From 1ed99ea9fad93387892ee5bde7bc8a9e42de2a47 Mon Sep 17 00:00:00 2001 From: winh Date: Mon, 22 May 2017 12:05:50 +0200 Subject: Add file names to Karma suite descriptions (!11597) --- spec/javascripts/test_bundle.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec/javascripts/test_bundle.js') diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 0464b5d2329..3b6c16adb65 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -14,10 +14,25 @@ window.gl = window.gl || {}; window.gl.TEST_HOST = 'http://test.host'; window.gon = window.gon || {}; +class PatchedSuite extends jasmine.Suite { + constructor(attrs) { + super(Object.assign(attrs, { + description: PatchedSuite.appendFileName(attrs.description), + })); + } + + static appendFileName(description) { + return `${description} (${PatchedSuite.currentFileName})`; + } +} + +jasmine.Suite = PatchedSuite; + // render all of our tests const testsContext = require.context('.', true, /_spec$/); testsContext.keys().forEach(function (path) { try { + PatchedSuite.currentFileName = path.replace(/^\.\//, 'spec/javascripts/'); testsContext(path); } catch (err) { console.error('[ERROR] Unable to load spec: ', path); -- cgit v1.2.1