phantomjs - 使用 PhantomJS 运行实习生 : window is undefined

标签 phantomjs intern

我已按照此处描述的所有步骤进行操作:https://github.com/theintern/intern/wiki/Using-Intern-with-PhantomJS

我的实习生配置如下:

define({
  proxyPort: 9000,
  proxyUrl: 'http://localhost:9000/',
  environments: [
    { browserName: 'phantom' }
  ],
  maxConcurrency: 3,
  useSauceConnect: false,
  webdriver: {
    host: 'localhost',
    port: 4444
  },
  reporters: ['runner'],
  useLoader: {
    'host-node': 'dojo/dojo',
    'host-browser': 'node_modules/dojo/dojo.js'
  },
  loader: {
    packages: [
      { name: 'myApp', location: '...' }
    ],
    baseUrl: '...',
    paths: {...}
  },
  suites: [
    'test/hello'
  ],
  functionalSuites: [],
  excludeInstrumentation: /(^test(\/|\\)|reporters|node_modules)/
});

我运行 phantomJS

.\node_modules\.bin\phantomjs --webdriver 4444 --webdriver-loglevel='debug' 

它监听 4444。

我什至禁用了 Windows 防火墙,但我仍然得到

ReferenceError: window is not defined
    at ***.js:348:142
    at Function.vm.runInThisContext (***\node_modules\intern\node_modules\istanbul\lib\hook.js:163:16)
    at ***\node_modules\intern\node_modules\dojo\dojo.js:757:8
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

就好像 Intern 在节点上运行,而不是在 Phatom 中运行。 Phantom 的控制台也完全安静。

我错过了什么?或者有没有办法调试实习生的 Action ?谢谢

最佳答案

好吧,我终于明白了。

我一直在使用实习生

.\node_modules\.bin\intern-client config=test/intern

本该如此

.\node_modules\.bin\intern-runner config=test/intern

事实是,intern-runnerintern-client是两个不同的应用程序,一个是通过WebDriver与浏览器一起运行,另一个是与Node一起运行。尽管我不止一次地阅读和重新阅读文档,但它并没有引起我的注意。也许应该在那里突出显示区别。

希望这对某人有帮助)

关于phantomjs - 使用 PhantomJS 运行实习生 : window is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22389240/

相关文章:

javascript - 在 sinon 中 stub 依赖函数

java - PhantomJS 驱动程序未单击页面中的元素,但未引发错误

javascript - 实习生覆盖范围不包括卸载源

report - 排除实习生报道范围内的文件,我是否需要一名定制记者?

intern - 如何使用通配符在 Intern 中指定测试套件?

intern - 如何运行 intern 来测试使用 node.js 运行的 dojo 应用程序?

javascript - phantomjs:document.querySelectorAll() 不适用于动态页面

测试 GoInstant 客户端代码(最好使用 PhantomJS)

windows - 使用 Phantom JS 将文件夹中的所有 HTML 文件转换为 PNG

javascript - 通过php执行脚本后获取html页面