【问题标题】:Karma Uncaught RangeError: Maximum call stack size exceededKarma Uncaught RangeError:超出最大调用堆栈大小
【发布时间】:2017-12-04 23:02:57
【问题描述】:

我在尝试运行 grunt karma:debug 时收到来自 Karma 的此错误:

11 11 2017 00:00:00.000:INFO [Chrome 62.0.3202 (Linux 0.0.0)]: Connected on socket /#AAAA-AAAAAAAAAAAAAAA with id 99999999
Chrome 61.0.0000 (Linux 0.0.0) ERROR
  Uncaught RangeError: Maximum call stack size exceeded
  at http://localhost:9876/context.html
Chrome 61.0.0000 (Linux 0.0.0) ERROR
  Uncaught RangeError: Maximum call stack size exceeded
  at http://localhost:9876/context.html
Chrome 61.0.0000 (Linux 0.0.0): Executed 0 of 0 ERROR (1.035 secs / 0 secs)

可能是什么原因?在提交一些大的 JSON 文件后,它开始在一夜之间发生。如果我在没有 JSON 文件的情况下返回提交,该命令将再次开始工作。

【问题讨论】:

    标签: testing gruntjs karma-runner


    【解决方案1】:

    我在我的karma.conf.js 文件中发现了问题:

    config.set({
        ...
        files: [
            ...
            { pattern: "path/to/fixtures/**/*.json" },
            ...
        ]
    

    该行使 Karma 将 JSON 文件包含在 HTML 页面中,并且似乎对我添加的 JSON 文件的数量有问题。解决方案是告诉 Karma 不要将这些文件包含在 HTML 中,而是将它们用作 WebServer:

    config.set({
        ...
        files: [
            ...
            { pattern: "path/to/fixtures/**/*.json", included: false },
            ...
        ]
    

    相关文档为here:

    included
    Type. Boolean
    Default. true
    Description. Should the files be included in the browser using
                 <script> tag? Use false if you want to load them manually,
                 eg. using Require.js.
    

    【讨论】:

      【解决方案2】:

      确保您只分配了一次组件变量,最好只在顶部 beforeEach 中。

      component = fixture.componentInstance - 这不应该在每个描述中都给出。

      【讨论】:

        猜你喜欢
        • 2014-06-11
        • 2017-05-23
        • 2018-03-18
        • 2011-12-01
        • 1970-01-01
        • 2022-09-29
        • 2016-10-19
        • 2017-12-12
        相关资源
        最近更新 更多