Open mattensor opened 3 years ago
I had this issue too. For me it was because I was returning undefined
as a TableName in my jest-dynalite-config.js file.
Perhaps it's the same for you?
@jonoirwinrsa might be right here. If you remove your other afterEnvSetup
file, does this work? Can I see your dynalite config?
It works if I remove my other afterEnvSetup setup file, but I need that to mock external api calls.
Here's my jest-dynalite-config.ts file
const tables = [
{
TableName: 'conversations',
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'S' },
{ AttributeName: 'userId', AttributeType: 'S' }
],
KeySchema: [{ AttributeName: 'id', KeyType: 'HASH' }],
BillingMode: 'PAY_PER_REQUEST',
GlobalSecondaryIndexes: [
{
IndexName: 'userConversationsIndex',
KeySchema: [{ AttributeName: 'userId', KeyType: 'HASH' }],
Projection: { ProjectionType: 'ALL' }
}
]
}
]
module.exports = {
tables,
basePort: 8000
}
jest.config.ts
import { pathsToModuleNameMapper } from 'ts-jest/utils'
import { compilerOptions } from './tsconfig.json'
export default {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/'
}),
preset: 'jest-dynalite',
setupFiles: ['<rootDir>/jestEnvironmentSetup.ts'],
setupFilesAfterEnv: ['<rootDir>/jestServiceWorkerSetup.ts']
}
Ok. Can you narrow down which test is causing this error and maybe post details about this test? It's likely you get an error like this if a DB call happens outside a test (as this library tears down the server after each test).
This could be due to a forgotten await
keyword, or a side effect which is kicked off by another function and not being awaited.
I've created a minimal representation code.
https://github.com/yamatatsu/represent-jest-dynalite-database-is-not-open
I guess the condition of this error is below:
In my case, the work arround I found is to extend the timeout period.
test('test case' async () => {...}, 60_000 /* long enough */)
Hey there
I get the following error when running dynalite.
I have an existing setupFilesAfterEnv file in which there are conflicts. When I remove it, my tests work - but I have no dynalite goodness :(
afterEnvSetup
I've tried the granular approach importing the start / stop fns individually. The out of the box solution and on an individual file. Still no luck
Would be great to get some help