airbnb/jest-wrap

docs need a note that built-in wrap plugins work with "each", not "all"

Open

#18 opened on 2018年10月10日

GitHub で見る
 (4 comments) (0 reactions) (0 assignees)JavaScript (14 forks)github user discovery
help wanted

Repository metrics

Stars
 (40 stars)
PR merge metrics
 (PR metrics pending)

説明

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" } } }

コントリビューターガイド