Internet窗口未定义

Intern - window is undefined

本文关键字:未定义 窗口 Internet      更新时间:2023-09-26

我在intern-geezer中运行了一个测试循环,大约有二十个非常相似的测试成功运行。然后突然:

FATAL ERROR
ReferenceError: window is not defined

并且循环停止。在我的代码中没有对windowdocument的显式调用。它是纯JS。我用的是实习医生,2.2.2。错误堆栈中引用的行号完全没有意义。他们离这里很远。

我已经阅读了从命令切换的建议:

./node_modules/.bin/intern-client config=tests/intern

至:

./node_modules/.bin/intern-runner config=tests/intern

但我不想连接到服务器或打开浏览器(那里发生了一个单独的、奇怪的加载错误,这似乎是geezer特有的)。我想在命令行执行此操作。感谢你的帮助,我对实习生完全陌生。

window是一个浏览器对象,因此它在Node中不可用。如果您想在节点客户端(intern-client)中独占运行测试,则需要确保您没有使用(并且您的依赖项都没有使用)任何引用浏览器对象(如documentwindownavigator等)的代码。

如果堆栈跟踪行号关闭,则可能是代码覆盖率检测。您可以通过将Internet配置中的excludeInstrumentation属性设置为/./来禁用它。

您可能在实习生配置文件中将"Html"设置为报告程序

intern.reporters = [
    { id: 'Html' },
    { id: 'JUnit', filename: 'test-reports/quality/functional/junit.xml' },
    ...,
];