Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
e86194d1
W
wechaty
项目概览
.www.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e86194d1
编写于
10月 26, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#40 try to fix unit test in CI!
上级
ce50196d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
35 deletion
+43
-35
index.ts
index.ts
+2
-2
package.json
package.json
+3
-3
src/puppet-web/browser.ts
src/puppet-web/browser.ts
+21
-15
test/webdriver.spec.ts
test/webdriver.spec.ts
+0
-1
test/wechaty.spec.ts
test/wechaty.spec.ts
+17
-14
未找到文件。
index.ts
浏览文件 @
e86194d1
...
...
@@ -14,7 +14,7 @@ import Wechaty from './src/wechaty'
import
log
from
'
./src/brolog-env
'
const
version
=
require
(
'
./package.json
'
).
version
const
VERSION
=
require
(
'
./package.json
'
).
version
export
default
Wechaty
export
{
...
...
@@ -30,5 +30,5 @@ export {
,
UtilLib
,
Wechaty
,
log
// for convenionce use npmlog with environment variable LEVEL
,
version
,
VERSION
}
package.json
浏览文件 @
e86194d1
...
...
@@ -24,13 +24,13 @@
"tslint"
:
"tslint
\"
{bin,example,src,test}/**/*.ts
\"
&& tsc --noEmit"
,
"sloc"
:
"sloc . --details --format cli-table --keys total,source,comment --exclude
\"
node_modules|doc
\"
&& sloc . --exclude
\"
node_modules|doc
\"
"
,
"pretest"
:
"npm run lint && npm run clean && npm run build"
,
"test"
:
"npm run test:
phantomjs && npm run test:
chrome"
,
"test"
:
"npm run test:chrome"
,
"posttest"
:
"npm run clean && npm run sloc"
,
"test:phantomjs"
:
"cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m
\"
dist/test/*.spec.js
\"
"
,
"test:phantomjs.bak"
:
"cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m
\"
dist/{src,test}/**/*.spec.js
\"
"
,
"test:chrome"
:
"cross-env LC_ALL=C WECHATY_LOG=
silly WECHATY_HEAD=chrome ava
--timeout=10m
\"
dist/{src,test}/**/*.spec.js
\"
"
,
"test:chrome"
:
"cross-env LC_ALL=C WECHATY_LOG=
info WECHATY_HEAD=chrome ava --ext js
--timeout=10m
\"
dist/{src,test}/**/*.spec.js
\"
"
,
"testdev"
:
"cross-env LC_ALL=C WECHATY_LOG=silly ava --ext ts --serial --verbose --fail-fast --timeout=3m"
,
"testdist"
:
"ava --ext ts --verbose --fail-fast --timeout=3m"
,
"testdist"
:
"
WECHATY_HEAD=phantomjs
ava --ext ts --verbose --fail-fast --timeout=3m"
,
"ava"
:
"cross-env LC_ALL=C WECHATY_LOG=verbose ts-node node_modules/.bin/ava
\"
{src,test}/**/*.spec.js
\"
"
,
"start"
:
"ts-node bin/client"
,
"dev"
:
"ts-node dev.ts"
,
...
...
src/puppet-web/browser.ts
浏览文件 @
e86194d1
...
...
@@ -12,14 +12,14 @@ import {
Builder
,
Capabilities
,
WebDriver
}
from
'
selenium-webdriver
'
}
from
'
selenium-webdriver
'
/* tslint:disable:no-var-requires */
const
retryPromise
=
require
(
'
retry-promise
'
).
default
// https://github.com/olalonde/retry-promise
import
Config
from
'
../config
'
import
Config
from
'
../config
'
import
StateMonitor
from
'
../state-monitor
'
import
log
from
'
../brolog-env
'
import
log
from
'
../brolog-env
'
import
{
CookieType
...
...
@@ -60,19 +60,21 @@ export class Browser extends EventEmitter {
this
.
state
.
target
(
'
open
'
)
this
.
state
.
current
(
'
open
'
,
false
)
//
fast
Url is used to open in browser for we can set cookies.
//
jump
Url is used to open in browser for we can set cookies.
// backup: 'https://res.wx.qq.com/zh_CN/htmledition/v2/images/icon/ico_loading28a2f7.gif'
const
fast
Url
=
'
https://wx.qq.com/zh_CN/htmledition/v2/images/webwxgeticon.jpg
'
const
jump
Url
=
'
https://wx.qq.com/zh_CN/htmledition/v2/images/webwxgeticon.jpg
'
// return co.call(this, function* () {
try
{
await
this
.
initDriver
()
// this.live = true
await
this
.
open
(
fast
Url
)
await
this
.
open
(
jump
Url
)
await
this
.
loadCookie
()
.
catch
(
e
=>
{
// fail safe
log
.
verbose
(
'
PuppetWeb
'
,
'
browser.loadSession(%s) exception: %s
'
,
this
.
setting
.
sessionFile
,
e
&&
e
.
message
||
e
)
log
.
verbose
(
'
PuppetWeb
'
,
'
browser.loadSession(%s) exception: %s
'
,
this
.
setting
.
sessionFile
,
e
&&
e
.
message
||
e
)
})
await
this
.
open
()
/**
...
...
@@ -159,13 +161,13 @@ export class Browser extends EventEmitter {
public
driver
(
newDriver
?:
WebDriver
|
null
):
WebDriver
|
void
{
if
(
newDriver
!==
undefined
)
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
driver(%s)
'
,
newDriver
?
newDriver
.
constructor
.
name
:
null
,
newDriver
?
newDriver
.
constructor
.
name
:
null
)
}
if
(
typeof
newDriver
!==
'
undefined
'
)
{
if
(
newDriver
!==
undefined
)
{
if
(
newDriver
)
{
this
.
_driver
=
newDriver
return
this
.
_driver
...
...
@@ -343,7 +345,7 @@ export class Browser extends EventEmitter {
/**
*
* if we use AVA t
o test, then this.clean will
cause problems
* if we use AVA t
est runner, then this.clean might
cause problems
* because there will be more than one instance of browser with the same nodejs process id
*
*/
...
...
@@ -386,7 +388,8 @@ export class Browser extends EventEmitter {
return
retryPromise
({
max
:
max
,
backoff
:
backoff
},
attempt
=>
{
log
.
silly
(
'
PuppetWebBrowser
'
,
'
clean() retryPromise: attempt %s time for timeout %s
'
,
attempt
,
timeout
)
,
attempt
,
timeout
)
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
getBrowserPids
()
...
...
@@ -549,7 +552,10 @@ export class Browser extends EventEmitter {
// log.verbose('PuppetWebBrowser', 'dead() emit a `dead` event because %s', msg)
// this.emit('dead', msg)
// }
if
(
this
.
state
.
target
()
===
'
open
'
&&
this
.
state
.
current
()
===
'
open
'
&&
this
.
state
.
stable
())
{
if
(
this
.
state
.
target
()
===
'
open
'
&&
this
.
state
.
current
()
===
'
open
'
&&
this
.
state
.
stable
()
)
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
dead() emit a `dead` event because %s
'
,
msg
)
this
.
emit
(
'
dead
'
,
msg
)
}
else
{
...
...
test/webdriver.spec.ts
浏览文件 @
e86194d1
// import * as path from 'path'
import
{
test
}
from
'
ava
'
// import {
...
...
test/wechaty.spec.ts
浏览文件 @
e86194d1
...
...
@@ -3,6 +3,7 @@ import { test } from 'ava'
import
{
Config
,
Contact
,
FriendRequest
,
IoClient
,
Message
,
Puppet
...
...
@@ -11,28 +12,30 @@ import {
,
Wechaty
,
log
,
version
,
VERSION
}
from
'
../
'
test
(
'
Wechaty Framework
'
,
t
=>
{
t
.
truthy
(
Wechaty
,
'
should export Wechaty
'
)
t
.
truthy
(
Message
,
'
should export Message
'
)
t
.
truthy
(
Contact
,
'
should export Contact
'
)
t
.
truthy
(
Room
,
'
should export Room
'
)
t
.
truthy
(
IoClient
,
'
should export IoClient
'
)
t
.
truthy
(
log
,
'
should export log
'
)
t
.
truthy
(
Puppet
,
'
should export Puppet
'
)
t
.
truthy
(
PuppetWeb
,
'
should export PuppetWeb
'
)
t
.
truthy
(
Contact
,
'
should export Contact
'
)
t
.
truthy
(
FriendRequest
,
'
should export FriendREquest
'
)
t
.
truthy
(
IoClient
,
'
should export IoClient
'
)
t
.
truthy
(
Message
,
'
should export Message
'
)
t
.
truthy
(
Puppet
,
'
should export Puppet
'
)
t
.
truthy
(
PuppetWeb
,
'
should export PuppetWeb
'
)
t
.
truthy
(
Room
,
'
should export Room
'
)
t
.
truthy
(
Wechaty
,
'
should export Wechaty
'
)
t
.
truthy
(
log
,
'
should export log
'
)
const
bot
=
Wechaty
.
instance
()
t
.
is
(
bot
.
version
(
true
),
version
,
'
should export version in package.json
'
)
t
.
is
(
bot
.
version
(
true
),
require
(
'
../package.json
'
).
version
,
'
should return version as the same in package.json
'
)
t
.
is
(
VERSION
,
require
(
'
../package.json
'
).
version
,
'
should export version in package.json
'
)
})
test
(
'
Wechaty Config setting
'
,
t
=>
{
t
.
truthy
(
Config
,
'
should export Config
'
)
t
.
truthy
(
Config
.
DEFAULT_HEAD
,
'
should has DEFAULT_HEAD
'
)
t
.
truthy
(
Config
.
DEFAULT_PUPPET
,
'
should has DEFAULT_PUPPET
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录