Error testing Email: Test timeout, ensure "done()" is called;

Hi.

I’m getting this error when testing an email.

Error: Test timeout, ensure "done()" is called;....

Below is the test. I’m not having problems sending emails using ethereal or Mailtrap, just when testing.

'use strict'

const Event = use('Event')

const Mail = use('Mail')


const { test } = use('Test/Suite')('Send Welcome Email')


test('send_welcome_email', async ({ assert }) => {

  const payload = {

    userName:'Jorge',

    companyName:'My Company'

  }

  await Mail.send('emails.company_created_internal', payload, (message) => {

    message

      .to('user@email.com')

      .from('no-responder@unenegocios.cl')

      .subject(`UneNegocios Admin: Nueva Empresa`)

  })

  assert.isNotNull('user','Email se envio')

})
1 Like

https://adonisjs.com/docs/4.1/testing-fakes#_mail_fake

Here explains how to run your test by faking the mailing feature.

For the timeout in case you decide not use fakes you can add timeout to the test suite by following here: Error: Test timeout

2 Likes

Thanks for your information!