-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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-config): normalize reporters
option defined in presets
#12769
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1416,6 +1416,55 @@ describe.each(['setupFiles', 'setupFilesAfterEnv'])( | |
}, | ||
); | ||
|
||
describe("preset with 'reporters' option", () => { | ||
beforeEach(() => { | ||
const Resolver = require('jest-resolve').default; | ||
Resolver.findNodeModule = jest.fn(name => { | ||
if (name === 'with-reporters/jest-preset') { | ||
return '/node_modules/with-reporters/jest-preset.json'; | ||
} | ||
|
||
return `/node_modules/${name}`; | ||
}); | ||
jest.doMock( | ||
'/node_modules/with-reporters/jest-preset.json', | ||
() => ({ | ||
reporters: ['default'], | ||
}), | ||
{virtual: true}, | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.dontMock('/node_modules/with-reporters/jest-preset.json'); | ||
}); | ||
|
||
test("normalizes 'reporters' option defined in preset", async () => { | ||
const {options} = await normalize( | ||
{ | ||
preset: 'with-reporters', | ||
rootDir: '/root/', | ||
}, | ||
{} as Config.Argv, | ||
); | ||
|
||
expect(options.reporters).toEqual([['default', {}]]); | ||
}); | ||
|
||
test("overrides 'reporters' option defined in preset", async () => { | ||
const {options} = await normalize( | ||
{ | ||
preset: 'with-reporters', | ||
reporters: ['summary'], | ||
rootDir: '/root/', | ||
}, | ||
{} as Config.Argv, | ||
); | ||
|
||
expect(options.reporters).toEqual([['summary', {}]]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm.. Edit: I just added a test, there is no change in behaviour. The test is passing on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if ideal, but not something we should change here anyways |
||
}); | ||
}); | ||
|
||
describe('runner', () => { | ||
let Resolver; | ||
beforeEach(() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps? I just missed that warning, better if it errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, that's always an error I think