jeudi 15 novembre 2018

Is it possible to test jest tests?

I want to make a tool that test different exercises. One exercise is unit-testing. Therefore I need to test whether the tests that are made by the student are good tests. So for example the student has the following code:

export class HelloWorld {
  public static showHello(): string {
    return 'Hello World!';
  }
}

With the following jest test:

import { HelloWorld } from '..';

describe(Hello World exercise, () => {
  test('Check function is defined', () => {
    expect(HelloWorld.showHello()).toBeDefined();
  });

  test('Empty input results in Hello World!', () => {
    expect(HelloWorld.showHello()).toBe('Hello World!');
  });
});

How can I test that the student did indeed test these two tests? I thought about

export const firstTest = test()...

And then test whether firstTest test the right thing. But the disadvantage is that you have to export every test for this solution.

Aucun commentaire:

Enregistrer un commentaire