Skip to content

Commit

Permalink
WEB-10010 Karma Server failure - WebStorm 7 & Jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
segrey committed Nov 18, 2013
1 parent ee844c2 commit 589062a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/intellijReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ var cli = require("./intellijCli.js")

function getOrCreateBrowserNode(tree, browser) {
var configFileNode = tree.configFileNode;
var browserNode = configFileNode.lookupMap[browser.id];
var browserNode = configFileNode.findChildNodeByKey(browser.id);
if (!browserNode) {
browserNode = configFileNode.addChild(browser.name, true, 'browser', null);
configFileNode.lookupMap[browser.id] = browserNode;
browserNode = configFileNode.addChildWithKey(browser.id, browser.name, true, 'browser', null);
browserNode.writeStartMessage();
}
return browserNode;
Expand All @@ -35,11 +34,10 @@ function getOrCreateLowerSuiteNode(browserNode, suiteNames, write) {
write(message + '\n');
continue;
}
var nextNode = node.lookupMap[suiteName];
var nextNode = node.findChildNodeByKey(suiteName);
if (!nextNode) {
var locationHint = intellijUtil.joinList(suiteNames, 0, i + 1, '.');
nextNode = node.addChild(suiteName, true, 'suite', locationHint);
node.lookupMap[suiteName] = nextNode;
nextNode.writeStartMessage();
}
node = nextNode;
Expand All @@ -48,14 +46,10 @@ function getOrCreateLowerSuiteNode(browserNode, suiteNames, write) {
}

function createSpecNode(suiteNode, suiteNames, specName) {
var specNode = suiteNode.lookupMap[specName];
if (specNode) {
throw Error("Spec node is already created");
}
var names = suiteNames.slice();
names.push(specName);
var locationHint = intellijUtil.joinList(names, 0, names.length, '.');
specNode = suiteNode.addChild(specName, false, 'test', locationHint);
var specNode = suiteNode.addChild(specName, false, 'test', locationHint);
specNode.writeStartMessage();
return specNode;
}
Expand Down
28 changes: 28 additions & 0 deletions lib/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ function TestSuiteNode(tree, id, parentNode, name, type, locationHint) {

inherit(TestSuiteNode, Node);

/**
* Returns child node by its name.
* @param childKey unique string that identifies this node (it can be node's name)
* @returns {?Node} child node (null, if no child node with such name found)
*/
TestSuiteNode.prototype.findChildNodeByKey = function(childKey) {
if (Object.prototype.hasOwnProperty.call(this.lookupMap, childKey)) {
return this.lookupMap[childKey];
}
return null;
};

TestSuiteNode.prototype.getStartCommandName = function () {
return 'testSuiteStarted';
};
Expand All @@ -138,6 +150,19 @@ TestSuiteNode.prototype.getFinishCommandName = function () {
* @returns {TestSuiteNode | TestNode}
*/
TestSuiteNode.prototype.addChild = function (childName, isChildSuite, nodeType, locationHint) {
return this.addChildWithKey(childName, childName, isChildSuite, nodeType, locationHint);
};

/**
*
* @param {String} childKey unique string that identifies this node (sometimes childName isn't enough)
* @param {String} childName node name (e.g. browser name / suite name / spec name)
* @param {Boolean} isChildSuite true if child node can have children
* @param {String} nodeType child node type (e.g. 'config', 'browser')
* @param {String} locationHint navigation info
* @returns {TestSuiteNode | TestNode}
*/
TestSuiteNode.prototype.addChildWithKey = function (childKey, childName, isChildSuite, nodeType, locationHint) {
if (this.isFinished) {
throw Error('Child node could be created for finished node!');
}
Expand All @@ -150,6 +175,9 @@ TestSuiteNode.prototype.addChild = function (childName, isChildSuite, nodeType,
child = new TestNode(this.tree, childId, this, childName, nodeType, locationHint);
}
this.children.push(child);
if (isChildSuite) {
this.lookupMap[childKey] = child;
}
return child;
};

Expand Down

0 comments on commit 589062a

Please sign in to comment.