weex-vdom-tester
Virtual-DOM test driver for Weex.
Usage
In Weex virtual-DOM test driver, you can create a Runtime
which can simulate a native app JavaScript runtime. The Runtime
instance can be initialized with a Weex JS framework like Vanilla, Vue, React etc.
Then in the runtime you can run a Instance
with JS Bundle which is based on the target framework.
This can be used to test whether the framework work well. For example: make sure a certain JS Bundle could generate a certain "real" DOM tree in renderer as expect, or do a certain series of JS-bridge calls.
See test/case.js
for some use case.
Weex JS runtime APIs
import {
Runtime,
DEFAULT_MODULES,
DEFAULT_COMPONENTS,
DEFAULT_ENV
} from 'weex-vdom-tester'
const runtime = new Runtime(jsFramework, {
})
runtime.onlog((type, args) => { ... })
runtime.onlog(type, (args) => { ... })
runtime.offlog((args) => { ... })
runtime.registerModules({
x: {
foo: (instance, document, ...args) => {},
bar: (instance, document, ...args) => {}
}
})
runtime.registerModules({
"modal": [
"alert",
"toast",
"prompt",
"confirm"
]
})
runtime.registerComponents([
x: { type: 'x', append: true }
])
Weex instance APIs
import { Instance } from 'weex-vdom-tester'
const instance = new Instance(runtime)
instance.id
instance.doc
instance.$create(code, config, data)
instance.$refresh(data)
instance.$destroy()
instance.$fireEvent(element, type, detail)
instance.$callback(callbackId, detail, isLast)
instance.$getRoot()
instance.oncall(moduleName, (methodName, args) => { ... })
instance.oncall(moduleName, methodName, (args) => { ... })
instance.oncall((moduleName, methodName, args) => { ... })
instance.mockModuleAPI(
moduleName, methodName,
(instance, document, originFunc, ...args) => { ... })
instance.getRealRoot()
instance.watchDOMChanges((target, changes) => { ... })
instance.watchDOMChanges(element, (target, changes) => { ... })
instance.history.callNative[{ timestamp, module, method, args }]
instance.history.callJS[{ timestamp, method, args }]
instance.history.refresh[{ timestamp, data }]
instance.play()
instance.pause()