Repository: freeCodeCamp/freeCodeCamp
File: api/src/exam-environment/utils/exam-environment.test.ts (TypeScript)

Code before:
          id: oid(),
          questions,
          type: ExamEnvironmentQuestionType.MultipleChoice
        }
      ];
      const data = {
        config,
        deprecated: false,
        prerequisites: [oid()],
        questionSets
      };

      expect(async () => {
        await fastifyTestInstance.prisma.examEnvironmentExam.create({
          data
        });
      }).not.toThrow();
    });
  });
  describe('ExamEnvironmentGeneratedExam', () => {
    afterAll(async () => {
      await fastifyTestInstance.prisma.examEnvironmentGeneratedExam.deleteMany(
        {}
      );
    });
    it('should throw if the schema changes, and remind to increment the `version` field by 1', () => {
      expect(async () => {
        await fastifyTestInstance.prisma.examEnvironmentGeneratedExam.create({
          data: {
            deprecated: false,
            examId: oid(),
            questionSets: [
              { id: oid(), questions: [{ answers: [oid()], id: oid() }] }
            ]
          }
        });
      }).not.toThrow();
    });
  });
  describe('ExamEnvironmentExamAttempt', () => {
    afterAll(async () => {
      await fastifyTestInstance.prisma.examEnvironmentExamAttempt.deleteMany(
        {}
      );
    });
    it('should throw if the schema changes, and remind to increment the `version` field by 1', () => {
      expect(async () => {
        await fastifyTestInstance.prisma.examEnvironmentExamAttempt.create({
          data: {
            examId: oid(),
            generatedExamId: oid(),

Review comment (bug):
```suggestion
    it('If this test fails and you've deliberately altered the schema, then increment the `version` field by 1', async () => {
```

Code after:
          id: oid(),
          questions,
          type: ExamEnvironmentQuestionType.MultipleChoice
        }
      ];
      const data = {
        config,
        deprecated: false,
        prerequisites: [oid()],
        questionSets
      };

      await fastifyTestInstance.prisma.examEnvironmentExam.create({
        data
      });
    });
  });
  describe('ExamEnvironmentGeneratedExam', () => {
    afterAll(async () => {
      await fastifyTestInstance.prisma.examEnvironmentGeneratedExam.deleteMany(
        {}
      );
    });
    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: {
          deprecated: false,
          examId: oid(),
          questionSets: [
            { id: oid(), questions: [{ answers: [oid()], id: oid() }] }
          ]
        }
      });
    });
  });
  describe('ExamEnvironmentExamAttempt', () => {
    afterAll(async () => {
      await fastifyTestInstance.prisma.examEnvironmentExamAttempt.deleteMany(
        {}
      );
    });
    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: {
          examId: oid(),
          generatedExamId: oid(),
          questionSets: [
            {
              id: oid(),
              questions: [
                { answers: [oid()], id: oid(), submissionTimeInMS: 0 }