1

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

我修改报告的原因是我需要suiteDone步骤生成的 xml 报告,而不是jasmineDone步骤。所以基本上我将所有代码从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
    }

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

4

1 回答 1

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.

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

于 2019-05-31T14:12:51.123 回答