【发布时间】:2020-11-23 05:36:42
【问题描述】:
如何在 cypress 中使用 2 个 gmail 帐户
我创建了 2 个文件 credentialsclient.json 和 credentials.json 并创建 2 个 gmail 令牌文件。
现在我想在其他测试中对两封电子邮件使用 get-messages 功能。
我在我的 index.js 文件中编写选定的代码,
module.exports = (on, config) => {
on("before:browser:launch", (browser = {}, launchOptions) => {
// `args` is an array of all the arguments that will
// be passed to browsers when it launches
console.log(launchOptions.args); // print all current args
if (browser.family === "chromium" && browser.name !== "electron") {
// auto open devtools
launchOptions.args.push("--auto-open-devtools-for-tabs");
// allow remote debugging
// launchOptions.args.push("--remote-debugging-port=9221");
// whatever you return here becomes the launchOptions
} else if (browser.family === "firefox") {
// auto open devtools
launchOptions.args.push("-devtools");
}
return launchOptions;
});
on("task", {
"gmail:get-messages": async args => {
const messages = await gmail_tester.get_messages(
path.resolve(__dirname, "credentialsclient.json"),
path.resolve(__dirname, "gmail_tokenclient.json"),
args.options
);
return messages;
}
});
};
对于下一个 gmail,我想使用另一个功能
on("task", {
"gmail:get-messages": async args => {
const messages = await gmail_tester.get_messages(
path.resolve(__dirname, "credentials.json"),
path.resolve(__dirname, "gmail_token.json"),
args.options
);
return messages;
}
但在使用相同 gmail 的两个测试中。
我怎样才能分开帐户。
谢谢
【问题讨论】:
标签: javascript node.js gmail-api cypress