Error: Test timeout

Hello, I’m new in TDD, and start with adonis browser testing. sometime get this error on my test

1. Show error on login invalid
  Error: Test timeout, ensure "done()" is called; if returning a Promise, ensure it resolves.
    at Test._parseError (/home/sucipto/Dev/js/devhunt/node_modules/japa/src/Test.js:109:16)
    at Callable.args.run.then.then.catch (/home/sucipto/Dev/js/devhunt/node_modules/japa/src/Test.js:195:21)
    at <anonymous>

and here is my test code

'use strict'

const { test, trait } = use('Test/Suite')('Login Page')

const Factory = use('Factory')

trait('Test/Browser')

test('Show error on login invalid', async({ assert, browser }) => {
  
    // Visit login page
    const page = await browser.visit('/auth/login')
  
    // Type invalid credential
    await page
      .type("[name='email']", "invalid@email.com")
      .type("[name='password']", "invalid-secret")
      .submitForm('form')
      .waitForNavigation()
  
    // Return to login page
    await page.assertPath('/auth/login')
  
})

Each test have a timeout of 2000 milliseconds to make sure you are tests are not hanging forever.

At times browser tests can be slow and hence you can increase timeout as follows.

test('Show error on login invalid', async({ assert, browser }) => {
}).timeout(6000)

Or set it to 0 to disable timeouts.

1 Like