We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, Do you have any idea to mock connection to Database.
I have test file
const mockGetRepository = { findOne: jest.fn(), }; import User from 'models/User'; jest.mock('components/DatabaseConnection', () => { return { __esModule: true, default: { addModels: (m: any) => { return; }, getRepository: () => mockGetRepository, models: {User}, }, }; }); import models from 'models'; import UserRepository from 'repositories/UserRepository'; describe('UserRepository test', () => { it('findById test - user exist', async (done) => { mockGetRepository.findOne.mockImplementationOnce(() => { return new models.User({id: 123}); }); const user = await UserRepository.findById(123); expect(user).toEqual({id: 123}); done(); }); });
when I try to create a new instance of User I got error
Model not initialized: User cannot be instantiated. "User" needs to be added to a Sequelize instance
Any idea?
The text was updated successfully, but these errors were encountered:
i have same issue.. as i guess, this has something to do with the decoder pattern.. TT TT
Sorry, something went wrong.
No branches or pull requests
Hi,
Do you have any idea to mock connection to Database.
I have test file
when I try to create a new instance of User I got error
Any idea?
The text was updated successfully, but these errors were encountered: