Skip to content

Instantly share code, notes, and snippets.

@olegpolyakov
Last active October 2, 2019 12:49
Show Gist options
  • Save olegpolyakov/319aa755f814ca1cd2a386c4a1f356d4 to your computer and use it in GitHub Desktop.
Save olegpolyakov/319aa755f814ca1cd2a386c4a1f356d4 to your computer and use it in GitHub Desktop.
Jest test runner
describe('Функции:', () => {
[].forEach((filename, index) => {
let exercise = require(`../exercises/${filename}/test`);
describe(`Упражнение ${index + 1}: ${exercise.title}`, () => {
let solution;
beforeEach(() => solution = require(`../exercises/${filename}`));
exercise.tests.forEach(({ description, assertion, async }) => {
if (async) {
it(description, done => assertion(solution, done));
} else {
it(description, () => assertion(solution));
}
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment