简体   繁体   English

Angular CLI ng测试错误

[英]Angular CLI ng test Errors

I've got TypeScript 2.1 and install the latest Angular CLI. 我有TypeScript 2.1并安装了最新的Angular CLI。 ng e2e will run, but ng test gives the error ng e2e将运行,但是ng test给出了错误

<--- Last few GCs --->

   52499 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1045.6 / 0 ms [allocation failure] [GC in old space requested].
   53547 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1048.7 / 0 ms [allocation failure] [GC in old space requested].
   54622 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1074.2 / 0 ms [last resort gc].
   55683 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1061.9 / 0 ms [last resort gc].


<--- JS stacktrace --->

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

Security context: 000000C0003C9E79 <JS Object>
    1: scanNumber [...typescript\lib\typescript.js:~4482] [pc=000002B5ABFA230E] (this=000000C0003E4649 <JS Global Object>)
    2: scan [..\typescript\lib\typescript.js:~4820] [pc=000002B5ABF09246] (this=00000348EBB58831 <an Object with map 000000BFCA178B91>)
    3: parseDelimitedList [\...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I tried deleting node_modules and ran npm i again and no luck. 我尝试删除node_modules并再次运行npm i ,但没有运气。 This is with no edits to any generated test files. 无需编辑任何生成的测试文件。

Definitely don't delete node_modules. 绝对不要删除node_modules。 You'll need to cd back into your project's home directory and run npm install to reinstall all of your node packages. 您需要CD返回到项目的主目录,然后运行npm install重新安装所有节点包。

Instead it's important that you understand the difference between memory and storage. 相反,重要的是您了解内存和存储之间的区别。 Memory has to do with your RAM (data in use on currently used applications) and storage has to do with your hard drive. 内存与RAM(当前使用的应用程序中使用的数据)有关,而存储与硬盘驱动器有关。 This suggests to me that you have too many things running in your browser, or you are somehow creating a huge amount in your application. 这向我表明您的浏览器中运行的东西太多,或者您正在以某种方式在应用程序中创建大量的东西。

Try to close your browsers and reopen. 尝试关闭浏览器并重新打开。 if that doesn't work then you'll need to take a look at your code for any logic that that is endless, like a for loop that never ends. 如果那行不通,那么您需要查看代码中是否存在无穷无尽的逻辑,例如永无休止的for循环。 try commenting out sections that you suspect and see if ng test works. 尝试注释掉您怀疑的部分,然后查看ng test有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM