我已按照此处描述的所有步骤进行操作: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-runner和intern-client是两个不同的应用程序,一个是通过WebDriver与浏览器一起运行,另一个是与Node一起运行。尽管我不止一次地阅读和重新阅读文档,但它并没有引起我的注意。也许应该在那里突出显示区别。
希望这对某人有帮助)
关于phantomjs - 使用 PhantomJS 运行实习生 : window is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22389240/