如何在执行量角器测试脚本时修复堆错误

时间:2019-06-11 13:49:57

标签: node.js typescript npm protractor

我正在执行使用“ npm测试”以打字稿编写的量角器测试用例。现在它不断抛出致命错误:接近堆限制的无效标记压缩-分配失败-JavaScript堆内存不足。有什么办法可以解决它,以及如何调试此类问题。

在Windows 10中运行我的脚本,尝试在package.json的脚本部分内添加--max-old-space-size = 4096,但它不起作用。也可以通过在窗口环境中设置NODE_OPTION来尝试

我的package.json:

{
    "name": "proex",
    "version": "0.0.1",
    "description": "Protractor , Jasmine and typescript",
    "main": "config.js",
    "dependencies": {
        "@types/jasmine": "^2.8.11",
        "@types/node": "^10.12.8",
        "browserstack-local": "^1.3.4",
        "exceljs": "^1.7.0",
        "log4js": "^3.0.6",
        "properties": "^1.2.1",
        "properties-reader": "0.0.16",
        "protractor": "^5.4.1",
        "protractor-fail-fast": "^3.1.0",
        "shelljs": "^0.8.2"
    },
    "devDependencies": {
        "protractor-beautiful-reporter": "^1.2.7"
    },
    "scripts": {
        "pretest": "npm run tsc",
        "test": "protractor ConvertedJSFiles/config.js",
        "tsc": "tsc"
    },
    "types": [
        "jasmine",
        "jasminewd2",
        "node"
    ],
    "keywords": [
        "Protractor",
        "Typescript"
    ]
}

以前它能够加载应用程序,但现在它正在抛出


> proex@0.0.1 tsc C:\workspace\Connect
> tsc


> proex@0.0.1 test C:\workspace\Connect
> protractor ConvertedJSFiles/config.js

[18:12:22] I/launcher - Running 1 instances of WebDriver
[18:12:22] I/direct - Using ChromeDriver directly...

DevTools listening on ws://127.0.0.1:63023/devtools/browser/ecfc13cc-152b-4fec-b059-84d5d10e023b

<--- Last few GCs --->
8)[34140:000002CCC1667640]    17265 ms: Mark-sweep 1402.5 (1430.0) -> 1401.8 (1434.5) MB, 1298.6 / 0.0 ms  (+ 0.0 ms in 61 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1302 ms) (average mu = 0.095, current mu = 0.003) a[34140:000002CCC1667640]    18232 ms: Mark-sweep 1407.2 (1434.5) -> 1407.1 (1439.5) MB, 847.0 / 0.0 ms  (+ 107.9 ms in 83 steps since start of marking, biggest step 37.2 ms, walltime since start of marking 964 ms) (average mu = 0.061, current mu = 0.016)

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0000010F9CA5C5C1]
Security context: 0x007c48e9e6e1 <JSObject>
    1: getActualElement [0000018FE8099621] [C:\workspace\Connect\ConvertedJSFiles\commonLibraries\locatorHelper.js:~15] [pc=0000010F9CA65E05](this=0x015fe6c33db1 <LocatorHelper map = 0000022934BB9831>,elementValue=0x03bc188990f1 <String[19]: //img[@alt='close']>,elementType=0x03bc188b9891 <String[5]: Xpath>)
    2: new DeviceManagement [000001E14EA10919] [...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF6F6D9ECF5
 2: 00007FF6F6D781A6
 3: 00007FF6F6D78BB0
 4: 00007FF6F7009AAE
 5: 00007FF6F70099DF
 6: 00007FF6F7547724
 7: 00007FF6F753DE87
 8: 00007FF6F753C3FC
 9: 00007FF6F7545377
10: 00007FF6F75453F6
11: 00007FF6F70E84B7
12: 00007FF6F718019A
13: 0000010F9CA5C5C1
npm ERR! Test failed.  See above for more details.

C:\workspace\Connect>[44148:59184:0611/181428.982:ERROR:browser_process_sub_thread.cc(221)] Waited 140 ms for network service

0 个答案:

没有答案