Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,74 @@ exports[`preset throws when preset not found 1`] = `
<red></>"
`;

exports[`reporters throws an error if first value in the tuple is not a string 1`] = `
"<red><bold><bold>● </><bold>Reporter Validation Error</>:</>
<red></>
<red> Unexpected value for Path at index 0 of reporter at index 0</>
<red> Expected:</>
<red> <bold><red>string</><red></></>
<red> Got:</>
<red> <bold><green>number</><red></></>
<red> Reporter configuration:</>
<red> <bold><green>[</><red></></>
<red><bold><green> 123</><red></></>
<red><bold><green> ]</><red></></>
<red></>
<red> <bold>Configuration Documentation:</></>
<red> https://jestjs.io/docs/configuration</>
<red></>"
`;

exports[`reporters throws an error if second value in the tuple is not an object 1`] = `
"<red><bold><bold>● </><bold>Reporter Validation Error</>:</>
<red></>
<red> Unexpected value for Reporter Configuration at index 1 of reporter at index 0</>
<red> Expected:</>
<red> <bold><red>object</><red></></>
<red> Got:</>
<red> <bold><green>boolean</><red></></>
<red> Reporter configuration:</>
<red> <bold><green>[</><red></></>
<red><bold><green> "some-reporter",</><red></></>
<red><bold><green> true</><red></></>
<red><bold><green> ]</><red></></>
<red></>
<red> <bold>Configuration Documentation:</></>
<red> https://jestjs.io/docs/configuration</>
<red></>"
`;

exports[`reporters throws an error if second value is missing in the tuple 1`] = `
"<red><bold><bold>● </><bold>Reporter Validation Error</>:</>
<red></>
<red> Unexpected value for Reporter Configuration at index 1 of reporter at index 0</>
<red> Expected:</>
<red> <bold><red>object</><red></></>
<red> Got:</>
<red> <bold><green>undefined</><red></></>
<red> Reporter configuration:</>
<red> <bold><green>[</><red></></>
<red><bold><green> "some-reporter"</><red></></>
<red><bold><green> ]</><red></></>
<red></>
<red> <bold>Configuration Documentation:</></>
<red> https://jestjs.io/docs/configuration</>
<red></>"
`;

exports[`reporters throws an error if value is neither string nor array 1`] = `
"<red><bold><bold>● </><bold>Reporter Validation Error</>:</>
<red></>
<red> Reporter at index 0 must be of type:</>
<red> <bold><green>array or string</><red></></>
<red> but instead received:</>
<red> <bold><red>number</><red></></>
<red></>
<red> <bold>Configuration Documentation:</></>
<red> https://jestjs.io/docs/configuration</>
<red></>"
`;

exports[`rootDir throws if the options is missing a rootDir property 1`] = `
"<red><bold><bold>● </><bold>Validation Error</>:</>
<red></>
Expand Down
52 changes: 52 additions & 0 deletions packages/jest-config/src/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,58 @@ describe('reporters', () => {
['jest-junit', {outputName: 'report.xml'}],
]);
});

it('throws an error if value is neither string nor array', async () => {
expect.assertions(1);
await expect(
normalize(
{
reporters: [123],
rootDir: '/root/',
},
{} as Config.Argv,
),
).rejects.toThrowErrorMatchingSnapshot();
});

it('throws an error if first value in the tuple is not a string', async () => {
expect.assertions(1);
await expect(
normalize(
{
reporters: [[123]],
rootDir: '/root/',
},
{} as Config.Argv,
),
).rejects.toThrowErrorMatchingSnapshot();
});

it('throws an error if second value is missing in the tuple', async () => {
expect.assertions(1);
await expect(
normalize(
{
reporters: [['some-reporter']],
rootDir: '/root/',
},
{} as Config.Argv,
),
).rejects.toThrowErrorMatchingSnapshot();
});

it('throws an error if second value in the tuple is not an object', async () => {
expect.assertions(1);
await expect(
normalize(
{
reporters: [['some-reporter', true]],
rootDir: '/root/',
},
{} as Config.Argv,
),
).rejects.toThrowErrorMatchingSnapshot();
});
});

describe('transform', () => {
Expand Down