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

expect("エ").toEqual("ア") does not throw Error #14160

Open
shigurenimo opened this issue Sep 25, 2024 · 2 comments
Open

expect("エ").toEqual("ア") does not throw Error #14160

shigurenimo opened this issue Sep 25, 2024 · 2 comments
Labels
bug Something isn't working bun:test Something related to the `bun test` runner

Comments

@shigurenimo
Copy link

What version of Bun is running?

1.1.30

What platform is your computer?

Darwin 24.0.0 arm64 arm

What steps can reproduce the bug?

  1. make empty directory
  2. run bun init
  3. make a test file index.test.ts
  4. run bun test

スクリーンショット 2024-09-26 1 11 42

What is the expected behavior?

should be

✗ toEqual [3.75ms]
3 | test("toEqual", () => {
4 |   expect("").toEqual("")
5 | })
6 | 
7 | test("toBe", () => {
8 |   expect("").toBe("")
                  ^
error: expect(received).toBe(expected)

Expected: ""
Received: ""

What do you see instead?

import { test, expect } from "bun:test"

test("toEqual", () => {
  expect("ア").toEqual("ア")
})

test("toBe", () => {
  expect("a").toBe("ア")
})
$ bun test
bun test v1.1.30-canary.37 (117e1b38)

index.test.ts:
✓ toEqual
✓ toBe [1.04ms]

 2 pass
 0 fail
 2 expect() calls
Ran 2 tests across 1 files. [9.00ms]

Additional information

I had to use Katakana in my project. the cause is Katakana?

import { test, expect } from "bun:test"

test("Katakana and Alphabet", () => {
  expect("ア").toEqual("a") // fail
})

test("Alphabet and Katakana", () => {
  expect("a").toEqual("ア") // fail
})

test("Katakana and Katakana", () => {
  expect("フ").toEqual("ア") // pass
})

test("Kanji and Katakana", () => {
  expect("了").toEqual("ア") // fail
})
@shigurenimo shigurenimo added bug Something isn't working needs triage labels Sep 25, 2024
@shigurenimo shigurenimo changed the title expect("エ").toEqual("ア") does not throw error expect("エ").toEqual("ア") does not throw Error Sep 25, 2024
@dylan-conway
Copy link
Collaborator

This is most likely bug in our diff formatter. It is appending invalid UTF-8 sequences, which will error when we try to create the error message with WTF::String::fromUTF8, which will then fail to create the error for toEqual

@dylan-conway dylan-conway added bun:test Something related to the `bun test` runner and removed needs triage labels Sep 25, 2024
@shigurenimo
Copy link
Author

to avoid this problem, it's possible to use an array for now.

expect(["エ"]).toEqual(["ア"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:test Something related to the `bun test` runner
Projects
None yet
Development

No branches or pull requests

2 participants