Can I use sqlite in memory?


#1

I would like to use sqlite in memory in my tests, but I always get this error:

info: serving app on http://127.0.0.1:4000

{ Error: SQLITE_CANTOPEN: unable to open database file errno: 14, code: 'SQLITE_CANTOPEN' }

Here is my .env.testing file:

HOST=127.0.0.1
PORT=4000
NODE_ENV=testing

DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=
DB_USER=root
DB_PASSWORD=
DB_DATABASE=':memory:'

#2

I haven’t tried this but something like this should work:
In config/database

  sqlite_testing: {
    client: 'sqlite3',
    connection: ':memory:',
    useNullAsDefault: true
  },

and DB_CONNECTION should then be sqlite_testing


#3

Thanks @Tsume, it did the trick.

You have to make use of the vowfile.js file in order to run your Database migrations before the tests, and to those having some issues such as:

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

Error: SQLITE_ERROR: no such table

You will find these configurations useful: