Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jest-each): fixes error message with incorrect count of missing arguments #12464

Merged
merged 6 commits into from Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -48,6 +48,7 @@
- `[jest-config]` Pass `moduleTypes` to `ts-node` to enforce CJS when transpiling ([#12397](https://github.com/facebook/jest/pull/12397))
- `[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]` 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/expect-utils]` [**BREAKING**] Fix false positives when looking for `undefined` prop ([#8923](https://github.com/facebook/jest/pull/8923))
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