whatsapp-web.js/tests/helper.js
Rajeh Taher 883d7e4eda
Store: remove all mentions of window.Store (#127077)
* Store: remove all mentions of window.Store

* Apply suggestion from @BenyFilho

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

---------

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
2026-03-01 16:49:21 -03:00

32 lines
No EOL
813 B
JavaScript

const { Client, LocalAuth } = require('..');
require('dotenv').config();
const remoteId = process.env.WWEBJS_TEST_REMOTE_ID;
if(!remoteId) throw new Error('The WWEBJS_TEST_REMOTE_ID environment variable has not been set.');
function createClient({authenticated, options: additionalOpts}={}) {
const options = {};
if(authenticated) {
const clientId = process.env.WWEBJS_TEST_CLIENT_ID;
if(!clientId) throw new Error('No session found in environment.');
options.authStrategy = new LocalAuth({
clientId
});
}
const allOpts = {...options, ...(additionalOpts || {})};
return new Client(allOpts);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports = {
sleep,
createClient,
remoteId,
};