jest-test-each
Version:
run parametrised tests easily [typesafe] without text tables or arrays of arrays.
361 lines (360 loc) • 12.5 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const runner_env_1 = require("../utils/runner-env");
const utils_1 = require("../utils/utils");
describe('Groups test.Should be no suites', () => {
const rootName = 'Test pack - root';
const test = () => runner_env_1.createTest(rootName);
const config = { groupBySuites: true, numericCases: false, concurrent: false };
beforeEach(() => {
runner_env_1.cleanup();
});
describe('should be no suites - all singles', () => {
its()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "a: 1, b: 1, c: 1",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
],
"tests": Array [
"a: 1, b: 1, c: 1",
],
"totalEntities": 2,
}
`));
}));
});
describe('should be suites - 1 single at start', () => {
its()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }, { b: '2' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }, { b: '2' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "b: 1",
},
Object {
"name": "b: 2",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
"a: 1",
],
"tests": Array [
"b: 1",
"b: 2",
],
"totalEntities": 4,
}
`));
}));
});
describe('should be suites - 2 singles at start', () => {
its()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }, { c: '2' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }, { c: '2' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "c: 1",
},
Object {
"name": "c: 2",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
"a: 1, b: 1",
],
"tests": Array [
"c: 1",
"c: 2",
],
"totalEntities": 4,
}
`));
}));
});
describe('should be no suites - 1 single at end', () => {
its()
.config(config)
.each([{ a: '1' }, { a: '2' }])
.each([{ b: '1' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }, { a: '2' }])
.each([{ b: '1' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "a: 1, b: 1",
},
Object {
"name": "a: 2, b: 1",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
],
"tests": Array [
"a: 1, b: 1",
"a: 2, b: 1",
],
"totalEntities": 3,
}
`));
}));
});
describe('should be no suites - 2 singles at end', () => {
its()
.config(config)
.each([{ a: '1' }, { a: '2' }])
.each([{ b: '1' }])
.each([{ c: '1' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }, { a: '2' }])
.each([{ b: '1' }])
.each([{ c: '1' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "a: 1, b: 1, c: 1",
},
Object {
"name": "a: 2, b: 1, c: 1",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
],
"tests": Array [
"a: 1, b: 1, c: 1",
"a: 2, b: 1, c: 1",
],
"totalEntities": 3,
}
`));
}));
});
describe('should be suites - singles at start and at end', () => {
its()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }, { b: '2' }])
.each([{ c: '1' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }, { b: '2' }])
.each([{ c: '1' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "b: 1, c: 1",
},
Object {
"name": "b: 2, c: 1",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
"a: 1",
],
"tests": Array [
"b: 1, c: 1",
"b: 2, c: 1",
],
"totalEntities": 4,
}
`));
}));
});
describe('should be suites - several singles at start and at end', () => {
its()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }, { c: '2' }])
.each([{ d: '1' }])
.each([{ e: '1' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }, { c: '2' }])
.each([{ d: '1' }])
.each([{ e: '1' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "c: 1, d: 1, e: 1",
},
Object {
"name": "c: 2, d: 1, e: 1",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
"a: 1, b: 1",
],
"tests": Array [
"c: 1, d: 1, e: 1",
"c: 2, d: 1, e: 1",
],
"totalEntities": 4,
}
`));
}));
});
describe('should be suites - several singles at start, in center and end', () => {
its()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }, { c: '2' }])
.each([{ d: '1' }])
.each([{ e: '1' }])
.each([{ f: '1' }, { f: '2' }])
.each([{ g: '1' }])
.run(t => utils_1.success());
it('wrapper', () => __awaiter(void 0, void 0, void 0, function* () {
test()
.config(config)
.each([{ a: '1' }])
.each([{ b: '1' }])
.each([{ c: '1' }, { c: '2' }])
.each([{ d: '1' }])
.each([{ e: '1' }])
.each([{ f: '1' }, { f: '2' }])
.each([{ g: '1' }])
.run(t => utils_1.success());
yield runner_env_1.waitFinished();
expect(runner_env_1.result.tests.length).toBeGreaterThan(0);
utils_1.assertAll(() => expect(runner_env_1.result).toMatchInlineSnapshot(`
Object {
"failures": Array [],
"passes": Array [
Object {
"name": "f: 1, g: 1",
},
Object {
"name": "f: 2, g: 1",
},
Object {
"name": "f: 1, g: 1",
},
Object {
"name": "f: 2, g: 1",
},
],
"skips": Array [],
"suites": Array [
"Test pack - root",
"a: 1, b: 1",
"c: 1, d: 1, e: 1",
"c: 2, d: 1, e: 1",
],
"tests": Array [
"f: 1, g: 1",
"f: 2, g: 1",
"f: 1, g: 1",
"f: 2, g: 1",
],
"totalEntities": 8,
}
`));
}));
});
});