Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

351
Views
La variable 'correo electrónico' no debe inicializarse en la declaración

Estoy tratando de crear un generador aleatorio para correos electrónicos en mi código Cypress

este es mi ejemplo:

 export function userEmail(): string { let email = "", domainName = "", possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (let i = 0; i < tabSize9; i++) email += possible.charAt(Math.floor(Math.random() * possible.length)); domainName += possible.charAt(Math.floor(Math.random() * possible.length)); return `${email}@${domainName}.com`; }

también funciona para mí, pero el problema es que cuando inicio mi script eslint, me dice que la variable de correo electrónico no debe inicializarse en la declaración, incluso mi variable de nombre de dominio

Alguna ayuda !

gracias de antemano

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Simplemente divida las declaraciones en 3 líneas diferentes

 let email = ""; let domainName = ""; let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
about 4 years ago · Juan Pablo Isaza Report

0

Prueba esto:

 export function userEmail(): string { const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; let email = ""; let domainName = ""; for (let i = 0; i < tabSize9; i++){ email += possible.charAt(Math.floor(Math.random() * possible.length)); domainName += possible.charAt(Math.floor(Math.random() * possible.length)); } return `${email}@${domainName}.com`; }
about 4 years ago · Juan Pablo Isaza Report

0

También puede usar faker.js para generar correos electrónicos aleatorios.

  1. Instale faker js con npm install @faker-js/faker --save-dev

  2. Para que Faker funcione correctamente, debe verificar si estas opciones de compilador están configuradas correctamente en su archivo tsconfig:

 { "compilerOptions": { "esModuleInterop": true, "moduleResolution": "Node" } }
  1. en tu prueba
 import { faker } from '@faker-js/faker'; export function userEmail(): string { return faker.internet.email(); }

Puede jugar con el tipo de correos electrónicos aleatorios que desea generar. Al igual que si desea mantener el nombre de dominio o primero, el apellido constante, etc. Consulte el documento Faker Js

 faker.internet.email(firstName?: string, lastName?: string, provider?: string, options?: { allowSpecialCharacters: boolean } = { allowSpecialCharacters: false }): string faker.internet.email() // => "Larry_Ratke85@yahoo.com" faker.internet.email() // 'Kassandra4@hotmail.com' faker.internet.email('Jeanne', 'Doe') // 'Jeanne63@yahoo.com' faker.internet.email('Jeanne', 'Doe', 'example.fakerjs.dev') // 'Jeanne_Doe88@example.fakerjs.dev' faker.internet.email('Jeanne', 'Doe', 'example.fakerjs.dev', { allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.fakerjs.dev'
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!