refactor: remove jest and lint vitest (#62330)

This commit is contained in:
Oliver Eyton-Williams
2025-09-24 09:27:03 +02:00
committed by GitHub
parent d96d528e8c
commit 51eba06a7d
25 changed files with 253 additions and 1813 deletions
@@ -97,7 +97,7 @@ describe('Exam Environment mocked Math.random', () => {
describe('generateExam()', () => {
it('should generate a randomized exam without throwing', () => {
const _randomizedExam = generateExam(exam);
expect(() => generateExam(exam)).not.toThrow();
});
it('should generate an exam matching with the correct number of question sets', () => {
@@ -199,7 +199,9 @@ describe('Exam Environment mocked Math.random', () => {
describe('validateAttempt()', () => {
it('should validate a correct attempt', () => {
validateAttempt(generatedExam, examAttempt.questionSets);
expect(() =>
validateAttempt(generatedExam, examAttempt.questionSets)
).not.toThrow();
});
it('should invalidate an incorrect attempt', () => {
@@ -422,6 +424,7 @@ describe('Exam Environment Schema', () => {
await fastifyTestInstance.prisma.examEnvironmentExam.deleteMany({});
});
// eslint-disable-next-line vitest/expect-expect
it("If this test fails and you've deliberately altered the schema, then increment the `version` field by 1", async () => {
const configQuestionSets = [
{
@@ -490,6 +493,7 @@ describe('Exam Environment Schema', () => {
{}
);
});
// eslint-disable-next-line vitest/expect-expect
it("If this test fails and you've deliberately altered the schema, then increment the `version` field by 1", async () => {
await fastifyTestInstance.prisma.examEnvironmentGeneratedExam.create({
data: {
@@ -508,6 +512,7 @@ describe('Exam Environment Schema', () => {
{}
);
});
// eslint-disable-next-line vitest/expect-expect
it("If this test fails and you've deliberately altered the schema, then increment the `version` field by 1", async () => {
await fastifyTestInstance.prisma.examEnvironmentExamAttempt.create({
data: {
+1 -1
View File
@@ -138,7 +138,7 @@ describe('errorHandling', () => {
expect(res.statusCode).toEqual(400);
});
test('should return the error message if the status is not 500 ', async () => {
test('should return the error message if the status is not 500', async () => {
const res = await fastify.inject({
method: 'GET',
url: '/test-bad-request'
+6 -22
View File
@@ -670,18 +670,16 @@ Happy coding!
const response = await superPut('/update-my-username').send({
username: 'TwaHa1'
});
expect(response.body).toStrictEqual({
message: 'flash.username-updated',
type: 'success',
variables: { username: 'TwaHa1' }
});
const user = await fastifyTestInstance.prisma.user.findFirst({
where: { email: 'foo@bar.com' }
});
expect(user?.username).toEqual('twaha1');
expect(response.body).toStrictEqual({
message: 'flash.username-updated',
type: 'success',
variables: { username: 'TwaHa1' }
});
expect(response.statusCode).toEqual(200);
});
@@ -725,20 +723,6 @@ Happy coding!
expect(existingUser.statusCode).toEqual(400);
});
test('PUT returns 200 status code with "success" message', async () => {
await superPut('/update-my-username').send({ username: 'twaha3' });
const response = await superPut('/update-my-username').send({
username: 'TWaha3'
});
expect(response.body).toStrictEqual({
message: 'flash.username-updated',
type: 'success',
variables: { username: 'TWaha3' }
});
expect(response.statusCode).toEqual(200);
});
test('PUT /update-my-username returns 400 status code when username is too long', async () => {
const username = 'a'.repeat(1001);
const response = await superPut('/update-my-username').send({
@@ -899,7 +883,7 @@ Happy coding!
expect(response.statusCode).toEqual(200);
});
test('PUT with empty strings clears the values in about settings ', async () => {
test('PUT with empty strings clears the values in about settings', async () => {
const initialResponse = await superPut('/update-my-about').send({
about: 'Teacher at freeCodeCamp',
name: 'Quincy Larson',
-2
View File
@@ -205,8 +205,6 @@ export function setupServer(): void {
If you are seeing this error, the root cause is likely an error thrown in the beforeAll hook.`);
await fastifyTestInstance.prisma.$runCommandRaw({ dropDatabase: 1 });
// Due to a prisma bug, this is not enough, we need to --force-exit jest:
// https://github.com/prisma/prisma/issues/18146
await fastifyTestInstance.close();
});
}