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
// Create a Weex JavaScript runtime for a certain Weex JS framework.// You can also simulate the native environment which includes// global env variables, native modules & components.const runtime = jsFramework // modules: DEFAULT_MODULES, // components: DEFAULT_COMPONENTS // env: DEFAULT_ENV // Listen `nativeLog` calls.// The `type` is in `['debug', 'log', 'info', 'warn', 'error']`.// If no `type` defined than it will listen all type of logs.runtimeruntimeruntime // Register more modules and components.// You can simulate all module APIs by this.runtime// Also if the vdom tester have implemented the module, you can just pass// an Array of method names to register them.runtime// Register native components.runtime
Weex instance APIs
// Create a Weex instance in a certain runtime.const instance = runtime// Each instance has an id.instanceid// Each instance has a document object to record what it will render.instancedoc // Send commands to Weex JS runtime about this instance.// See more details in Weex documentations.instanceinstanceinstanceinstanceinstanceinstance // Listen `callNative` from Weex JS runtime.// The module API would always run even you don't listen it.instanceinstanceinstance // Mock default behavior of module APIsinstance // Get JSON object from the real instance document.instance // Watch changes of a certain element or its children.// The default element is the root.instanceinstance // The history of `callNative` and `callJS`instancehistorycallNative timestamp module method args instancehistorycallJS timestamp method args instancehistoryrefresh timestamp data // Control the connection status to Weex JS runtime.instanceinstance