I'm developing an application with Adonis v5 but its test runner isn't finished. So, my workaround is to apply Jest in its place. I got this working but I'm having trouble importing types from Adonis.
In any model, I have the following import:
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
To solve the alias, I added this rule in jest.config.js
:
moduleNameMapper: {
'^App(.*)$': '<rootDir>/app$1',
'^@ioc:Adonis/Lucid/Database$': '@adonisjs/lucid/build/src/Database/index.js',
'^@ioc:Adonis/Lucid/Orm$': '@adonisjs/lucid/build/adonis-typings/orm.d.ts',
//'^@ioc:Adonis/Core/Validator$': '',
},
The third rule points to the previous import. Inside of the pointed file, I found the declaration of a module which exports the desired types.
declare module '@ioc:Adonis/Lucid/Orm' {
import { ScopeFn, LucidModel, HooksDecorator, ...
...
The complete file is this.
When I run Jest, I get this error. What am I missing? Before I forget, I'm using ts-jest
to define the settings of Jest.
esModuleInterop
set to true in tsconfig? – Coxalgia