Skip to content

Commit

Permalink
fix(jest-each): fixes error message with incorrect count of missing a…
Browse files Browse the repository at this point in the history
…rguments (#12464)
  • Loading branch information
flakolefluk committed Apr 13, 2022
1 parent 59d3e51 commit fb18e9a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -66,6 +66,7 @@
- `[jest-config, jest-haste-map]` Allow searching for tests in `node_modules` by exposing `retainAllFiles` ([#11084](https://github.com/facebook/jest/pull/11084))
- `[jest-core]` [**BREAKING**] Exit with status `1` if no tests are found with `--findRelatedTests` flag ([#12487](https://github.com/facebook/jest/pull/12487))
- `[jest-each]` `%#` is not replaced with index of the test case ([#12517](https://github.com/facebook/jest/pull/12517))
- `[jest-each]` Fixes error message with incorrect count of missing arguments ([#12464](https://github.com/facebook/jest/pull/12464))
- `[jest-environment-jsdom]` Make `jsdom` accessible to extending environments again ([#12232](https://github.com/facebook/jest/pull/12232))
- `[jest-environment-jsdom]` Log JSDOM errors more cleanly ([#12386](https://github.com/facebook/jest/pull/12386))
- `[jest-environment-node]` Add `MessageChannel`, `MessageEvent` to globals ([#12553](https://github.com/facebook/jest/pull/12553))
Expand Down
Expand Up @@ -54,7 +54,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .describe throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -67,7 +67,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .describe throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -129,7 +129,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .describe.only throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -142,7 +142,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .describe.only throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -204,7 +204,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .fdescribe throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -217,7 +217,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .fdescribe throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -279,7 +279,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .fit throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -292,7 +292,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .fit throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -354,7 +354,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .it throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -367,7 +367,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .it throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -429,7 +429,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .it.only throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -442,7 +442,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .it.only throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -504,7 +504,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -517,7 +517,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -579,7 +579,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.concurrent throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -592,7 +592,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.concurrent throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -654,7 +654,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.concurrent.only throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -667,7 +667,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.concurrent.only throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -729,7 +729,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.concurrent.skip throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -742,7 +742,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.concurrent.skip throws error when there are no arguments for given headings 1`] = `
Expand Down Expand Up @@ -804,7 +804,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.only throws error when there are fewer arguments than headings when given one row 1`] = `
Expand All @@ -817,7 +817,7 @@ Received:
<red> 1,</>
<red>]</>

Missing <red>2</> arguments"
Missing <red>1</> argument"
`;

exports[`jest-each .test.only throws error when there are no arguments for given headings 1`] = `
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-each/src/validation.ts
Expand Up @@ -54,9 +54,10 @@ export const validateTemplateTableArguments = (
headings: Array<string>,
data: TemplateData,
): void => {
const missingData = data.length % headings.length;
const incompleteData = data.length % headings.length;
const missingData = headings.length - incompleteData;

if (missingData > 0) {
if (incompleteData > 0) {
throw new Error(
`Not enough arguments supplied for given headings:\n${EXPECTED_COLOR(
headings.join(' | '),
Expand Down

0 comments on commit fb18e9a

Please sign in to comment.