question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

test.each doesnt works with interpolation with object properties

See original GitHub issue
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)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sigveiocommented, 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. 🙂

1reaction
sigveiocommented, Jul 30, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

jest .each name access object key - javascript - Stack Overflow
Jest describe.each expects an array of arrays in the first parameter. If you pass in a 1D array, internally it will be mapped...
Read more >
Understanding Angular property binding and interpolation
Learn about property binding and interpolation so you can understand which method best suits the task at hand.
Read more >
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Karate | Test Automation Made Simple.
Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
Read more >
A tour of the Dart language
' 'STRING INTERPOLATION is very handy!'); Note: The == operator tests whether two objects are equivalent. Two strings are equivalent if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found