茉莉花的修改后的JUnit xml报告程序提供RangeError:超出最大调用堆栈大小

时间:2019-05-31 13:57:28

标签: javascript junit jasmine protractor jasmine-reporters

我正在使用Jasmine JUnit Reports的修改版(可在此处找到:https://github.com/angular/protractor-cookbook/tree/master/jasmine-junit-reports),并收到RangeError: Maximum call stack size exceeded的错误消息

我修改报告的原因是我需要在suiteDone步骤而不是jasmineDone步骤生成的xml报告。因此,基本上我将所有代码从jasmineDone移到了suiteDone函数中,这现在引起了我所看到的错误。我对js来说还比较陌生,所以不能完全确定是否出现异步问题或类似问题。

这是堆栈跟踪和相关的代码位:

- RangeError: Maximum call stack size exceeded
        at getSuite (C:\Users\AutomationUser\application\admin\adminui\e2e\common-pages\reporter.js:248:26)
        at exportObject.QmetryReporter.self.suiteDone (C:\Users\AutomationUser\application\admin\adminui\e2e\common-pages\reporter.js:312:21)
        at exportObject.QmetryReporter.self.suiteDone (C:\Users\AutomationUser\application\admin\adminui\e2e\common-pages\reporter.js:322:22)

getSuite函数(第248行):

function getSuite(suite) {
    __suites[suite.id] = extend(__suites[suite.id] || {}, suite);
    return __suites[suite.id];
}

suiteDone函数的块:

self.suiteDone = function (suite) {
    suite = getSuite(suite); // this is line 312 from stacktrace
    if (suite._parent === UNDEFINED) {
        // disabled suite (xdescribe) -- suiteStarted was never called
        self.suiteStarted(suite);
    }
    suite._endTime = new Date();
    currentSuite = suite._parent;
    // below this line is the start of jasmineDone function that I moved into this function
    if (currentSuite) {
        // focused spec (fit) -- suiteDone was never called
        self.suiteDone(fakeFocusedSuite); // this is line 322 from stacktrace
    }

该问题似乎仅在运行更大的测试规格分组时才会发生。如果只运行一个测试文件,我不会遇到问题。

1 个答案:

答案 0 :(得分:0)

我已经遇到了很多次。适用于我的解决方案是使用increase-memory-limit软件包。只需全局安装它,然后在项目的根目录(increase-memory-limit在其中)中运行package.json。在安装所有依赖项之后以及开始测试之前,应该运行此命令。您将看到一堆类似于以下内容的输出

'~/app/node_modules/.bin/webdriver-manager' written successfully.
'~/app/node_modules/.bin/webdriver-manager.cmd' written successfully.
'~/app/node_modules/.bin/webpack' written successfully.
'~/app/node_modules/.bin/webpack-cli' written successfully.
'~/app/node_modules/.bin/webpack-cli.cmd' written successfully.
'~/app/node_modules/.bin/webpack-dev-server' written successfully.
'~/app/node_modules/.bin/webpack-dev-server.cmd' written successfully.
'~/app/node_modules/.bin/webpack.cmd' written successfully.
'~/app/node_modules/.bin/which' written successfully.
'~/app/node_modules/.bin/which.cmd' written successfully.

在那之后,您不应再看到此错误。我的完整回归套件非常大,当我尝试一次全部运行完整套件时,我总是总是看到相同的错误。上面的包装为我修复了它,自从我开始使用它以来就没有任何问题。