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

[jest-each] Relaxed the validation to allow multibyte characters in headings #11575

Merged
merged 4 commits into from
Aug 27, 2021

Conversation

hnisiji
Copy link
Contributor

@hnisiji hnisiji commented Jun 15, 2021

Summary

I fixed to be able to use Japanese and multibyte strings in the headings of jest.each as in Jest 26.

Since the release of Jest 27.0.0, Japanese headings are no longer available in jest-each.
The test case is as follows:

describe('jest.each & 日本語ヘッドライン', () => {
    test.each`
         入力 | 結果 
         ${1} | ${1}
         ${2} | ${4}
    `('2乗される', ({ 入力: input, 結果: expected }) => {
        expect(input**2).toEqual(expected);
     });
})

The output is follows:

> [email protected] test /Users/hnisiji/Documents/dev/jest-error
> jest

 FAIL  ./jest-each-with-japanese.spec.ts
  jest.each & 日本語ヘッドライン
    ✕ 2乗される (2 ms)

  ● jest.each & 日本語ヘッドライン › 2乗される

    Table headings do not conform to expected format:

    heading1 | headingN

    Received:

    "
             入力 | 結果 
             "

      1 | describe('jest.each & 日本語ヘッドライン', () => {
    > 2 |     test.each`
        |     ^
      3 |          入力 | 結果 
      4 |          ${1} | ${1}
      5 |          ${2} | ${4}

      at jest-each-with-japanese.spec.ts:2:5
      at Object.<anonymous> (jest-each-with-japanese.spec.ts:1:41)

I use Japanese in jest.each a lot, and I think that makes the test cases easier to understand.

Test plan

This PR works fine the test case above:

% cat jest-each-with-japanese.spec.ts 
describe('jest.each & 日本語ヘッドライン', () => {
    test.each`
         入力 | 結果 
         ${1} | ${1}
         ${2} | ${4}
    `('2乗される', ({ 入力: input, 結果: expected }) => {
        expect(input**2).toEqual(expected);
     });
})
[2021-06-15 23:25:06 hnisiji@hello:~/Documents/dev/jest-sample]
% ../jest/jest                       
yarn node v1.22.10
 PASS  ./jest-each-with-japanese.spec.ts
  jest.each & 日本語ヘッドライン
    ✓ 2乗される (2 ms)
    ✓ 2乗される

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.418 s, estimated 1 s
Ran all test suites.
✨  Done in 2.76s.

@hnisiji hnisiji changed the title [jest-each] Relaxed the validation to allow multibyte strings in headings [jest-each] Relaxed the validation to allow multibyte charactors in headings Jun 27, 2021
@hnisiji hnisiji changed the title [jest-each] Relaxed the validation to allow multibyte charactors in headings [jest-each] Relaxed the validation to allow multibyte characters in headings Jun 27, 2021
@hnisiji hnisiji force-pushed the relax-validation branch from e32a92d to 32e246b Compare July 6, 2021 23:01
@hnisiji
Copy link
Contributor Author

hnisiji commented Jul 11, 2021

@SimenB
Would you review this PR?
This issue is preventing me from updating to Jest 27...

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Could you add a test and a changelog entry? 🙂

@codecov-commenter
Copy link

Codecov Report

Merging #11575 (061c053) into master (84b3b03) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11575      +/-   ##
==========================================
- Coverage   69.01%   69.00%   -0.01%     
==========================================
  Files         312      312              
  Lines       16339    16339              
  Branches     4736     4736              
==========================================
- Hits        11276    11275       -1     
- Misses       5035     5036       +1     
  Partials       28       28              
Impacted Files Coverage Δ
packages/jest-each/src/validation.ts 100.00% <100.00%> (ø)
packages/expect/src/utils.ts 95.58% <0.00%> (-0.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84b3b03...061c053. Read the comment docs.

@hnisiji
Copy link
Contributor Author

hnisiji commented Aug 22, 2021

@SimenB
Thank you for your review!

We've added a few test cases to simply check some of Unicode characters.
This may not be a good test, but I think it's enough.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@SimenB SimenB merged commit 499ef4f into jestjs:master Aug 27, 2021
@github-actions
Copy link

This pull request 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 Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants