airbnb/jest-wrap
Vedi su GitHubdocs need a note that built-in wrap plugins work with "each", not "all"
Open
#18 aperta il 10 ott 2018
help wanted
Metriche repository
- Star
- (40 star)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
When attempting to override a global specified in the jest.config.js we've found it isn't overriden.
We have a set of globals which are basically stubs (in jest.config.js) e.g.
module.exports = {
globals: {
YJ: {
i18n: {
react: {}
}
}
},
...
Then when using jest-wrap to override the i18n key in that global we attempt to do:
const mockYJ = () => ({
i18n: {
old_components: {
form: "1234"
}
}
});
wrap()
.withGlobal("YJ", () => mockYJ)
.describe("Forms tests", function() {
beforeAll(function() {
console.log(YJ.i18n); // { react: {} }
// expected { i18n: { old_components: { form: "1234" } } }
But using beforeEach works as expected
wrap()
.withGlobal("YJ", () => mockYJ)
.describe("Forms tests", function() {
beforeEach(function() {
console.log(YJ.i18n); // { i18n: { old_components: { form: "1234" } } }