airbnb/jest-wrap
View on GitHubdocs need a note that built-in wrap plugins work with "each", not "all"
Open
#18 opened on Oct 10, 2018
help wanted
Repository metrics
- Stars
- (40 stars)
- PR merge metrics
- (PR metrics pending)
Description
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" } } }