提交 42a667d2 编写于 作者: fxy060608's avatar fxy060608

fix(automator): Compatible with jest@^28

上级 1defeaee
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}const e=new(t(require("./index.js")).default);let r;try{r=require("jest-environment-node")}catch(t){r=require(require.resolve("jest-environment-node",{paths:[process.cwd()]}))}module.exports=class extends r{constructor(t,e){super(t),process.env.UNI_AUTOMATOR_CONFIG?this.launchOptions=require(process.env.UNI_AUTOMATOR_CONFIG):this.launchOptions=t.testEnvironmentOptions}async setup(){await super.setup();const t=global;if(t.__init__){if(!t.program)throw Error("Program init failed")}else t.__init__=!0,this.launchOptions.platform=this.launchOptions.platform||process.env.UNI_PLATFORM,t.program=await e.launch(this.launchOptions),this.launchOptions.devtools&&this.launchOptions.devtools.remote&&await t.program.remote(!0);this.global.program=t.program}async teardown(){await super.teardown()}};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}const e=new(t(require("./index.js")).default);let n,r=!1;try{n=require("jest-environment-node")}catch(t){n=require(require.resolve("jest-environment-node",{paths:[process.cwd()]}))}n&&n.TestEnvironment&&(r=!0,n=n.TestEnvironment);module.exports=class extends n{constructor(t,e){super(r?{projectConfig:t}:t),process.env.UNI_AUTOMATOR_CONFIG?this.launchOptions=require(process.env.UNI_AUTOMATOR_CONFIG):this.launchOptions=t.testEnvironmentOptions}async setup(){await super.setup();const t=global;if(t.__init__){if(!t.program)throw Error("Program init failed")}else t.__init__=!0,this.launchOptions.platform=this.launchOptions.platform||process.env.UNI_PLATFORM,t.program=await e.launch(this.launchOptions),this.launchOptions.devtools&&this.launchOptions.devtools.remote&&await t.program.remote(!0);this.global.program=t.program}async teardown(){await super.teardown()}};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册