Skip to content
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

test.each doesnt works with interpolation with object properties #11704

Closed
polRk opened this issue Jul 29, 2021 · 8 comments
Closed

test.each doesnt works with interpolation with object properties #11704

polRk opened this issue Jul 29, 2021 · 8 comments

Comments

@polRk
Copy link

polRk commented Jul 29, 2021

test.each([
        {
            pageSize: 100,
            pageNumber: 1,
            // 0 - 10
            targetPageSize: 500,
            expected: [{pageSize: 500, pageNumber: 1}],
        },
        {
            pageSize: 500,
            pageNumber: 1,
            // 0 - 500
            targetPageSize: 500,
            expected: [{pageSize: 500, pageNumber: 1}],
        },
        {
            pageSize: 1000,
            pageNumber: 1,
            // 0 - 1000
            targetPageSize: 500,
            expected: [{pageSize: 500, pageNumber: 1}, {pageSize: 500, pageNumber: 2}],
        },
        {
            pageSize: 55,
            pageNumber: 10,
            // 495 - 550
            targetPageSize: 500,
            expected: [{pageSize: 500, pageNumber: 1}, {pageSize: 500, pageNumber: 2}],
        },
        {
            pageSize: 999,
            pageNumber: 2,
            // 999 - 1998
            targetPageSize: 500,
            expected: [{pageSize: 500, pageNumber: 2}, {pageSize: 500, pageNumber: 3}, {pageSize: 500, pageNumber: 4}],
        },
    ])(
        '.convertPagination({pageSize: $pageSize, pageNumber: $pageNumber}, $targetPageSize)',
        ({pageNumber, pageSize, targetPageSize, expected}) => {
            const reportDataRepository = new ReportDataRepository();
            // @ts-ignore
            const converted = reportDataRepository.convertPagination({pageSize, pageNumber}, targetPageSize);

            expect(converted).toStrictEqual(expected);
        },
    );

Log into console

    ✓ .convertPagination({pageSize: $pageSize, pageNumber: $pageNumber}, $targetPageSize) (30 ms)
    ✓ .convertPagination({pageSize: $pageSize, pageNumber: $pageNumber}, $targetPageSize) (1 ms)
    ✓ .convertPagination({pageSize: $pageSize, pageNumber: $pageNumber}, $targetPageSize) (1 ms)
    ✓ .convertPagination({pageSize: $pageSize, pageNumber: $pageNumber}, $targetPageSize) (1 ms)
    ✓ .convertPagination({pageSize: $pageSize, pageNumber: $pageNumber}, $targetPageSize) (1 ms)
@sigveio
Copy link
Contributor

sigveio commented Jul 29, 2021

Running the above, just replacing the content of the test with a dummy:

Screenshot 2021-07-29 at 21 22 39

Which Jest version are you running? Perhaps you could post the content of npx envinfo --preset jest?

@polRk
Copy link
Author

polRk commented Jul 30, 2021

  System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 10.14.0 - ~/.nvm/versions/node/v10.14.0/bin/node
    npm: 6.14.11 - ~/.nvm/versions/node/v10.14.0/bin/npm
  npmPackages:
    jest: 26.3.0 => 26.3.0 

@sigveio
Copy link
Contributor

sigveio commented Jul 30, 2021

This was fixed in Jest 27, so I'd suggest upgrading to the latest (27.0.6) if you can

@martindzejky
Copy link

Could you back-port this fix to Jest 24 please? I'm stuck on this version because of @vue/cli-plugin-unit-jest. 😞

@sigveio
Copy link
Contributor

sigveio commented Aug 25, 2021

Jest 24 is not supported any more and won't receive updates/back-porting. But I see @vue/cli-plugin-unit-jest added support for Jest 26 in vuejs/vue-cli/pull/6116 and appears to have included it in the ongoing beta for version 5.x. @cexbrayat has kindly started the work on Jest 27 in vuejs/vue-cli/pull/6627 as well - but I don't know if that would be able to make it into 5.x.

@martindzejky the vue-jest transformer appears to already support 27.x for both Vue 2 and 3 though. And @vue/cli-plugin-unit-jest mainly provide some Jest presets in addition to cli-tooling for initialising or migrating. So perhaps you can extract what you need and upgrade yourself if waiting on them adding support is not an option. 🙂

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants