unit tests fixin
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 58s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 58s
This commit is contained in:
@@ -148,7 +148,10 @@ describe('ProfileManager Authentication Flows', () => {
|
||||
render(<ProfileManager {...defaultProps} />);
|
||||
|
||||
const signInButton = screen.getByRole('button', { name: /^sign in$/i });
|
||||
fireEvent.click(signInButton);
|
||||
// Using fireEvent.submit on the form is more reliable for testing form submissions
|
||||
// and correctly handles the timing of state updates within the submit handler.
|
||||
const form = screen.getByTestId('auth-form');
|
||||
fireEvent.submit(form);
|
||||
|
||||
// We need to wait for the component to re-render with the loading state.
|
||||
// The most reliable way is to wait for the visual indicator (the spinner) to appear.
|
||||
|
||||
@@ -10,11 +10,14 @@ import { testPool } from '../tests/setup/test-db';
|
||||
// in tests use the test database.
|
||||
vi.mock('pg', async (importOriginal) => {
|
||||
const pg = await importOriginal<typeof import('pg')>();
|
||||
// We are mocking the Pool class.
|
||||
// The mock is a function that, when called with `new`, returns our testPool.
|
||||
// We replace the real Pool class with a mock class.
|
||||
// When `new Pool()` is called in the code under test, it will
|
||||
// instantiate this mock class. The constructor of our mock
|
||||
// immediately returns the `testPool` instance, ensuring that
|
||||
// all database operations use the test database.
|
||||
return {
|
||||
...pg,
|
||||
Pool: vi.fn(() => testPool),
|
||||
Pool: class MockPool { constructor() { return testPool; } },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -10,11 +10,14 @@ import bcrypt from 'bcrypt';
|
||||
// test database, resolving the circular dependency error.
|
||||
vi.mock('pg', async (importOriginal) => {
|
||||
const pg = await importOriginal<typeof import('pg')>();
|
||||
// We are mocking the Pool class.
|
||||
// The mock is a function that, when called with `new`, returns our testPool.
|
||||
// We replace the real Pool class with a mock class.
|
||||
// When `new Pool()` is called in the code under test, it will
|
||||
// instantiate this mock class. The constructor of our mock
|
||||
// immediately returns the `testPool` instance, ensuring that
|
||||
// all database operations use the test database.
|
||||
return {
|
||||
...pg,
|
||||
Pool: vi.fn(() => testPool),
|
||||
Pool: class MockPool { constructor() { return testPool; } },
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user