How to I can use 2 gmail accounts with cypress
I create 2 files credentialsclient.json and credentials.json and create 2 gmail token files.
Now I want to use get-messages function for two emails in other tests.
I am write selected code in my index.js file,
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;
}
});
};
And for next gmail I want use another function
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;
}
But in two tests using the same gmail.
How can I to separate the accounts.
Thanks