I'm trying to run jest tests with a Visual Studio Team Services build. These tests run fine and pass locally, but timeout when I run them in VSTS. For each async test that connects to the database, I get
Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
Here's my setup:
- graphql API using Apollo Server
- ArangoDB database insider a docker container
A typical test looks like this:
const database = require('../models')
...
describe('database setup', () => {
    it('sets up the database and it exists', () => {
        console.log(database.db)
        const collection=database.db.collection('agents')
        console.log(collection)
        return database.db.exists().then((result) => {
            expect(result).toBeTruthy()
        }).catch(err => {console.log(err)})
        .then(x => console.log(x)) 
    })
}
...
describe('help functions', () => {
    it('gets edge count for a node', async () => {
        let result = await database.getEdgeCount('nodes/1', 'inbound')
        expect(result).toBeGreaterThan(2)
    })
})
I'm running the tests in VSTS with an NPM task. The YAML for this task is basic:
steps:
- task: Npm@1
  displayName: npm test
  inputs:
    command: custom
    workingDir: api
    verbose: false
    customCommand: 'test --runInBand'
I know that the tests are connecting to the database because I can console.log the database object and get the database information.
Other things I've tried:
- Promise tests that don't hit the database, such as - it('foo', async () => { await Promise.resolve() expect(1).toEqual(1) }) These pass 
- Increasing the timeout to 30000. This causes a couple of the tests with database calls to return - null.
 
    