首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mocha-幻影错误加载资源mocha.js

mocha-幻影错误加载资源mocha.js
EN

Stack Overflow用户
提问于 2014-09-30 14:03:35
回答 1查看 761关注 0票数 2

我尝试运行摩卡-幻影并获得以下错误:

代码语言:javascript
复制
$ npm run test-phantom

> selenium-test@0.0.5 test-phantom /path/to/project/
> mocha-phantomjs test/client.html

Error loading resource file:///path/to/project//test/mocha.css (203). Details: Error opening /path/to/project//test/mocha.css: No such file or directory
Error loading resource file:///path/to/project//test/mocha.js (203). Details: Error opening /path/to/project//test/mocha.js: No such file or directory
Error loading resource file:///path/to/project//test/chai.js (203). Details: Error opening /path/to/project//test/chai.js: No such file or directory
TypeError: 'undefined' is not a function (evaluating 'mocha.ui('bdd')')

  file:///path/to/project//test/client.html:11

npm ERR! Linux 3.16.3-1-ARCH
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "test-phantom"
npm ERR! node v0.10.32
npm ERR! npm  v2.1.1
npm ERR! code ELIFECYCLE
npm ERR! selenium-test@0.0.5 test-phantom: `mocha-phantomjs test/client.html`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the selenium-test@0.0.5 test-phantom script.
npm ERR! This is most likely a problem with the selenium-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mocha-phantomjs test/client.html
npm ERR! You can get their info via:
npm ERR!     npm owner ls selenium-test
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /path/to/project/npm-debug.log

test/client.html文件如下:

代码语言:javascript
复制
<html>
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="mocha.css" />
  </head>
  <body>
    <div id="mocha"></div>
    <script src="mocha.js"></script>
    <script src="chai.js"></script>
    <script>
      mocha.ui('bdd');
      mocha.reporter('html');
      assert = chai.assert;
    </script>
    <script>
      if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
      else { mocha.run(); }
    </script>
  </body>
</html>

这几乎就是来自README的例子。我看到了三种可能的解决方案

  • 运行本地run服务器以提供mocha和chai资源。
  • 不知怎的,让幻影在node_modules中查找我想要的资源
  • 硬编码测试页面中资源的路径,我觉得这有点难看。

我可能搞错了.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-11 01:00:09

这样做也不算太丑:

代码语言:javascript
复制
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
...
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26122849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档