Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

spm test 生成 coverage 失败 #1020

Closed
hotoo opened this issue Sep 16, 2014 · 10 comments
Closed

spm test 生成 coverage 失败 #1020

hotoo opened this issue Sep 16, 2014 · 10 comments
Labels

Comments

@hotoo
Copy link
Member

hotoo commented Sep 16, 2014

测试 https://github.com/hotoo/detector 模块时:

$ spm -v
3.2.1
$ spm test
...
  516 passing (428ms)

undefined:1
Error: [jscoverage] unknow ENV!
^
SyntaxError: Unexpected token E
    at Object.parse (native)
    at cleanJSON (/usr/local/lib/node_modules/spm/node_modules/mocha-browser2/index.js:183:15)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/spm/node_modules/mocha-browser2/index.js:164:12)
    at EventEmitter.emit (events.js:104:17)
    at Socket.<anonymous> (/usr/local/lib/node_modules/spm/node_modules/mocha-browser2/index.js:76:15)
    at Socket.EventEmitter.emit (events.js:129:20)
    at _stream_readable.js:898:16
    at process._tickCallback (node.js:343:11)

   Fail to output _site/coverage.json
[SyntaxError: /Users/hotoo/workbench/hotoo/detector/_site/coverage.json: Unexpected token E]
@afc163
Copy link
Member

afc163 commented Sep 16, 2014

看看 /Users/hotoo/workbench/hotoo/detector/_site/coverage.json 的内容是啥

Error: [jscoverage] unknow ENV!

@sorrycc
Copy link
Member

sorrycc commented Sep 16, 2014

可能和代码书写方式有关,之前遇到过代码里扩展了原生对象 (Object, Array) 之类的导致生产不出来。

-- 
chencheng
Sent with Airmail

On September 16, 2014 at 6:26:56 PM, 闲耘™ (notifications@github.com) wrote:

$ spm -v
3.2.1
$ spm test
...
516 passing (428ms)

undefined:1
Error: [jscoverage] unknow ENV!
^
SyntaxError: Unexpected token E
at Object.parse (native)
at cleanJSON (/usr/local/lib/node_modules/spm/node_modules/mocha-browser2/index.js:183:15)
at EventEmitter. (/usr/local/lib/node_modules/spm/node_modules/mocha-browser2/index.js:164:12)
at EventEmitter.emit (events.js:104:17)
at Socket. (/usr/local/lib/node_modules/spm/node_modules/mocha-browser2/index.js:76:15)
at Socket.EventEmitter.emit (events.js:129:20)
at _stream_readable.js:898:16
at process._tickCallback (node.js:343:11)

Fail to output _site/coverage.json
[SyntaxError: /Users/hotoo/workbench/hotoo/detector/_site/coverage.json: Unexpected token E]


Reply to this email directly or view it on GitHub.

@hotoo
Copy link
Member Author

hotoo commented Sep 16, 2014

$ cat _site/coverage.json 
Error: [jscoverage] unknow ENV!

  http://127.0.0.1:8015/detector-cov.js:10
  http://127.0.0.1:8015/detector-cov.js:31
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://127.0.0.1:8015/tests/detector-spec.js:4
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2
  http://static.alipayobjects.com/seajs/seajs/2.2.0/sea.js:2

@hotoo
Copy link
Member Author

hotoo commented Sep 16, 2014

没有扩展 Object, Array 对象。

@hotoo
Copy link
Member Author

hotoo commented Sep 16, 2014

travis 也有同样的错误

https://travis-ci.org/hotoo/detector

@sorrycc sorrycc added the bug label Sep 17, 2014
@sorrycc
Copy link
Member

sorrycc commented Sep 18, 2014

detector.js 里把这句改了就能正常输出了。

- var window = this;
+ var win = this;

jscoverage 里通过 window 判断环境的逻辑。

if (typeof global === 'object') {
  BASE = global;
} else if (typeof window === 'object') {
  BASE = window;
} else {
  throw new Error('[jscoverage] unknow ENV!');
}

@sorrycc sorrycc closed this as completed Sep 18, 2014
@hotoo
Copy link
Member Author

hotoo commented Sep 18, 2014

8月13日还支持这个的。。

@hotoo
Copy link
Member Author

hotoo commented Sep 18, 2014

@sorrycc 辛苦了

@afc163
Copy link
Member

afc163 commented Sep 18, 2014

....楼上

@hotoo
Copy link
Member Author

hotoo commented Sep 18, 2014

即便如此,typeof window 也应该是 object(我在 web, phantom, node 中打印 typeof window 变量的值就是 "object"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants