Linting cleanup (#99)
* Add eslint and prettier dependencies and configs * Lint project.
This commit is contained in:
parent
dd6ec117d0
commit
e594d1075b
97 changed files with 26554 additions and 39840 deletions
|
|
@ -6,37 +6,43 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
|
||||
beforeAll(async () => {
|
||||
// Ensure test database is clean and created
|
||||
await sequelize.sync({ force: true });
|
||||
// Ensure test database is clean and created
|
||||
await sequelize.sync({ force: true });
|
||||
}, 30000);
|
||||
|
||||
beforeEach(async () => {
|
||||
// Clean all tables except Sessions to avoid conflicts
|
||||
try {
|
||||
const models = Object.values(sequelize.models);
|
||||
const nonSessionModels = models.filter(model => model.name !== 'Session');
|
||||
await Promise.all(nonSessionModels.map(model => model.destroy({ truncate: true, cascade: true })));
|
||||
} catch (error) {
|
||||
// Ignore errors during cleanup
|
||||
}
|
||||
// Clean all tables except Sessions to avoid conflicts
|
||||
try {
|
||||
const models = Object.values(sequelize.models);
|
||||
const nonSessionModels = models.filter(
|
||||
(model) => model.name !== 'Session'
|
||||
);
|
||||
await Promise.all(
|
||||
nonSessionModels.map((model) =>
|
||||
model.destroy({ truncate: true, cascade: true })
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
// Ignore errors during cleanup
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// Clean up sessions after each test
|
||||
try {
|
||||
const Session = sequelize.models.Session;
|
||||
if (Session) {
|
||||
await Session.destroy({ truncate: true });
|
||||
// Clean up sessions after each test
|
||||
try {
|
||||
const Session = sequelize.models.Session;
|
||||
if (Session) {
|
||||
await Session.destroy({ truncate: true });
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore errors during session cleanup
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore errors during session cleanup
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
try {
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
// Database may already be closed
|
||||
}
|
||||
}, 30000);
|
||||
try {
|
||||
await sequelize.close();
|
||||
} catch (error) {
|
||||
// Database may already be closed
|
||||
}
|
||||
}, 30000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue