Skip to content

Commit

Permalink
Add tests for jest-each and jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark1626 committed Jan 12, 2020
1 parent 16e0ad2 commit a05c8d7
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 0 deletions.
8 changes: 8 additions & 0 deletions e2e/__tests__/jasmineAsync.test.ts
Expand Up @@ -115,6 +115,14 @@ describe('async jasmine', () => {
expect(json.testResults[0].message).toMatch(/concurrent test fails/);
});

it('works with concurrent.each', () => {
const {json} = runWithJson('jasmine-async', ['concurrent-each.test.js']);
expect(json.numTotalTests).toBe(2);
expect(json.numPassedTests).toBe(1);
expect(json.numFailedTests).toBe(0);
expect(json.numPendingTests).toBe(1);
});

it("doesn't execute more than 5 tests simultaneously", () => {
const {json} = runWithJson('jasmine-async', ['concurrent-many.test.js']);
expect(json.numTotalTests).toBe(10);
Expand Down
25 changes: 25 additions & 0 deletions e2e/jasmine-async/__tests__/concurrent-each.test.js
@@ -0,0 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

it.concurrent.each(
[
[1, 2],
[2, 3],
],
'adds one to number',
Promise.resolve()
);
it.concurrent.skip.each(
[
[1, 2],
[2, 3],
],
'should skip this test',
Promise.resolve()
);
16 changes: 16 additions & 0 deletions e2e/jasmine-async/__tests__/concurrent.test.js
Expand Up @@ -11,3 +11,19 @@ it.concurrent('one', () => Promise.resolve());
it.concurrent.skip('two', () => Promise.resolve());
it.concurrent('three', () => Promise.resolve());
it.concurrent('concurrent test fails', () => Promise.reject());
it.concurrent.each(
[
[1, 2],
[2, 3],
],
'adds one to number',
Promise.resolve()
);
it.concurrent.skip.each(
[
[1, 2],
[2, 3],
],
'should skip this test',
Promise.resolve()
);
16 changes: 16 additions & 0 deletions packages/jest-each/src/__tests__/__snapshots__/array.test.ts.snap
Expand Up @@ -60,6 +60,10 @@ Instead was called with: undefined
"
`;

exports[`jest-each .it.concurrent throws an error when called with an empty array 1`] = `"Cannot read property 'mock' of undefined"`;

exports[`jest-each .it.concurrent throws an error when not called with an array 1`] = `"Cannot read property 'mock' of undefined"`;

exports[`jest-each .it.only throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
Expand All @@ -84,6 +88,18 @@ Instead was called with: undefined
"
`;

exports[`jest-each .test.concurrent throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
`;

exports[`jest-each .test.concurrent throws an error when not called with an array 1`] = `
"\`.each\` must be called with an Array or Tagged Template Literal.
Instead was called with: undefined
"
`;

exports[`jest-each .test.only throws an error when called with an empty array 1`] = `
"Error: \`.each\` called with an empty Array of table data.
"
Expand Down
Expand Up @@ -195,6 +195,14 @@ exports[`jest-each .it throws error when there are no arguments for given headin
"
`;
exports[`jest-each .it.concurrent throws an error when called with an empty string 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.concurrent throws error when there are fewer arguments than headings over multiple rows 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.concurrent throws error when there are fewer arguments than headings when given one row 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.concurrent throws error when there are no arguments for given headings 1`] = `"Cannot read property 'mock' of undefined"`;
exports[`jest-each .it.only throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
Expand Down Expand Up @@ -273,6 +281,45 @@ exports[`jest-each .test throws error when there are no arguments for given head
"
`;
exports[`jest-each .test.concurrent throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
`;
exports[`jest-each .test.concurrent throws error when there are fewer arguments than headings over multiple rows 1`] = `
"Not enough arguments supplied for given headings:
<green>a | b | expected</>
Received:
<red>Array [</>
<red> 0,</>
<red> 1,</>
<red> 1,</>
<red> 1,</>
<red> 1,</>
<red>]</>
Missing <red>2</> arguments"
`;
exports[`jest-each .test.concurrent throws error when there are fewer arguments than headings when given one row 1`] = `
"Not enough arguments supplied for given headings:
<green>a | b | expected</>
Received:
<red>Array [</>
<red> 0,</>
<red> 1,</>
<red>]</>
Missing <red>2</> arguments"
`;
exports[`jest-each .test.concurrent throws error when there are no arguments for given headings 1`] = `
"Error: \`.each\` called with a Tagged Template Literal with no data, remember to interpolate with \${expression} syntax.
"
`;
exports[`jest-each .test.only throws an error when called with an empty string 1`] = `
"Error: \`.each\` called with an empty Tagged Template Literal of table data.
"
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-each/src/__tests__/array.test.ts
Expand Up @@ -33,14 +33,17 @@ const getGlobalTestMocks = () => {
globals.describe.only = jest.fn();
globals.describe.skip = jest.fn();
globals.test.concurrent = jest.fn();
globals.it.concurrent = jest.fn();
return globals;
};

describe('jest-each', () => {
[
['test'],
['test', 'concurrent'],
['test', 'only'],
['it'],
['it', 'concurrent'],
['fit'],
['it', 'only'],
['describe'],
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-each/src/__tests__/template.test.ts
Expand Up @@ -32,14 +32,17 @@ const getGlobalTestMocks = () => {
globals.describe.only = jest.fn();
globals.describe.skip = jest.fn();
globals.test.concurrent = jest.fn();
globals.it.concurrent = jest.fn();
return globals;
};

describe('jest-each', () => {
[
['test'],
['test', 'concurrent'],
['test', 'only'],
['it'],
['it', 'concurrent'],
['fit'],
['it', 'only'],
['describe'],
Expand Down

0 comments on commit a05c8d7

Please sign in to comment.